How do I properly subtract two column vectors of class 'Double'
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Max Alger-Meyer
le 10 Mar 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.
Réponses (1)
Torsten
le 10 Mar 2022
You calculate
v = A*x - 1
in words: A*x - one
instead of
v = A*x - l
in words: A*x - el
Voir également
Catégories
En savoir plus sur Historical Contests dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!