How do I properly subtract two column vectors of class 'Double'
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi!
Im having trouble subtracting two column vectors of class = 'Double'
I have the equation:
v = A*x - l
A*x is very similar to L (both being 595x1), so i expect very small differences in the output variable v.
However, when running this in my function the output results are not as expected.
I tried isolating A*x and L and get them out of my function alone. I then did the subtraction manually in the command window afterwards and it computed the result i was expecting.
What am I missing?
3 Kommentare
Max Alger-Meyer
am 10 Mär. 2022
@Mohammed Sahan As Tosten mentioned, this code is trivial, and correct. So if the output isn't as expected, that likely means that either you are mistaken and the values of A*x and L are not similar, or at some point between when that operation takes place and when you look at the output, 'v' is getting changed. Be sure to put a breakpoint on the line that the subtraction takes place, and check the values of A*x and L in your command window. Then, put another breakpoint on the next line and check the values of 'v'. If the values of 'v' are as expected, then 'v' is likely getting modified later on in your function or script. You'll have to post the function and inputs if you need anything more than that for us to help you.
Antworten (1)
Torsten
am 10 Mär. 2022
You calculate
v = A*x - 1
in words: A*x - one
instead of
v = A*x - l
in words: A*x - el
Siehe auch
Kategorien
Mehr zu Historical Contests finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!