How do I fix the error "Line 10: Parse error at 2: usage might be invalid MATLAB syntax"?

clc
Vb=[0 -12];
Va=(-18*cosd(60)-18*sind(60));
Vba=Vb-Va;
magnitude_Vba=norm(Vba);
Angle_Vba=atand(Vba(2)/Vba(1));
Abnormal=Vb(2)^2/100;
Ab=(-Abnormal-3);
Aa=2*cosd(60) 2*sind(60);--- this line is getting the error
Aba=Ab-Aa;
magnitude_Aba=norm(Aba);
Angle_Aba=atand(Aba(2)/Aba(1));
%Display

回答(2 个)

What is unclear about the error message? Clearly you're missing something between 2*cosd(60) and 2*sind(60), perhaps an operator. As it is, yes the line does not make sense.
You either need an arithmetic operator (addition, subtraction, muyltiplication, division or the element-wise vectorized versions of them) or create ‘Aa’ as a matrix.
Assuming you want it as a matrix, this will work:
Aa = [2*cosd(60) 2*sind(60)]; % --- this line is getting the error
and will work with the rest of your code (producing Angle_Aba=48.6), although I have no idea what you actually want to do.

3 个评论

I was missing a "+" sign between the two. Now I keep getting an error for line 13 that says "index exceeds matrix dimensions"
Well, yes, since Aba has only one element, Aba(2) doesn't exist.
Clearly, you've made another mistake. Perhaps you should proofread your code.
Exactly.
What are your data, and what do you want to do with them?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by