Inner matrix dimensions must agree HELP
이전 댓글 표시
x= 0:(pi/90):(pi/2);
o=sqrt(2)*(sqrt((1/pi)*(2+x.^2)-(1-((2*x)/pi))*((sin((pi/4)-(x/2)))).^2/((pi/4)-(x/2))));
plot (x,i)
I need to plot this but it is giving me the error "mtimes Inner matrix dimensions must agree". Any help on how I can fix this
also can anyone help me on how to do sin^2(x) in matlab? I have searched but with no sure answer I have tried to use the trigonometric identity (1-cos(2x))/2 but can anyone help me on how to do it without the identity
답변 (2개)
Matt Tearle
2011년 3월 23일
In the middle of that line you have
(1-((2*x)/pi))*((sin((pi/4)-(x/2)))).^2
That should be an array multiply (.*), not a matrix multiply.
Also, your plot command should be plot(x,o), not i. I assume that's just a typo in your question.
Jose
2011년 3월 23일
0 개 추천
댓글 수: 1
Matt Tearle
2011년 3월 23일
1. Please start new questions for, well, new questions. Use the comments for follow-up discussion *about the same MATLAB topic*
2. plot(180*x/pi,o)
3. Looking closer, I notice that there's also a division by x (sin^2(...)/(pi/4-x/2). That should also be an array divide (./).
4. But overall, you should play with the algebra a bit before force-feeding it to MATLAB. You can simplify this expression such that you don't even need that divide.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!