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!