Inner matrix dimensions must agree HELP
Mostrar comentarios más antiguos
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
Respuestas (2)
Matt Tearle
el 23 de Mzo. de 2011
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
el 23 de Mzo. de 2011
0 votos
1 comentario
Matt Tearle
el 23 de Mzo. de 2011
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.
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!