clc;
clear all;
d1=200;
d2=1;
a3=135;
a4=135;
a5=135;
theta2=linspace(0,350,50);
theta3=linspace(0,180,40);
theta4=linspace(0,270,40);
theta5=linspace(0,180,40);
c2=cosd(theta2)
c3=cosd(theta3);
c5=cosd(theta5);
c34=cosd(theta3+theta4);
s2=sind(theta2);
s3=sind(theta3);
s5=sind(theta5);
s34=sind(theta3+theta4);
px = (a3.*(c2.*c3))-(a5.*((s2.*s5)-(c5.*c2.*c34)))+(a4.*c2.*c34);
py = (a3.*c3.*s2)+(a5.*(c5.*s2.*c34)+(c2.*s5))+(a4.*s2.*c34);
pz = d1(ones(1,50)) + d2 + (a3.*s3)+(a5.*c5.*s34)+(a4.*s34);
[EDITED, Jan, please use a proper code formatting - thanks]

 채택된 답변

Geoff Hayes
Geoff Hayes 2015년 4월 5일

0 개 추천

Venkata - the error message is
Error using .*
Matrix dimensions must agree.
Error in *** (line 20)
px = (a3.*(c2.*c3))-(a5.*((s2.*s5)-(c5.*c2.*c34)))+(a4.*c2.*c34);
Note that this line of code is doing several incorrect element-wise multiplications between arrays that are 1x40 and 1x50 which is incorrect. If you want to use the .* then left and right operands must be of the same dimension or at least one must be a scalar. Put a breakpoint in your code (at this line) and run the above. When the debugger pauses at this line look at all the variables and ask yourself if their dimensions make sense given the problem that you are trying to solve.

댓글 수: 7

Ajay
Ajay 2015년 4월 5일
how to place a breakup point in this code
Geoff Hayes
Geoff Hayes 2015년 4월 5일
Look at debugging process and features for details on setting breakpoints and debugging your code.
Ajay
Ajay 2015년 4월 5일
i am not able to get the breakup point can you help me put sir
Geoff Hayes
Geoff Hayes 2015년 4월 5일
What is preventing you from putting a breakpoint at this line? Is the above script in a function/script?
Ajay
Ajay 2015년 4월 5일
px = (a3.*c2.*c3)-(a5.*s2.*s5)+(a5.*c5.*c2.*c34)+(a4.*c2.*c34);
in this case if i am using breakpoint also it is not executing
Geoff Hayes
Geoff Hayes 2015년 4월 5일
I'm not clear on what you mean in your above statement. What do you mean by if i am using breakpoint also it is not executing?
Ajay
Ajay 2015년 4월 5일
I am using breakpoint on that line with a red dot on the code line number and then executing the line, then also i am getting the error as "matrix dimensions must agree"

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

질문:

2015년 4월 5일

댓글:

2015년 4월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by