How do I properly subtract two column vectors of class 'Double'
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Max Alger-Meyer
2022 年 3 月 10 日
@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.
回答 (1 件)
Torsten
2022 年 3 月 10 日
You calculate
v = A*x - 1
in words: A*x - one
instead of
v = A*x - l
in words: A*x - el
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!