lihaitao123 发表于 2011-5-28 12:10

作图出现的问题:Matrix must be square?

clear all
clc;
syms a1 a2beta2 miu alpha2 f sigma1 alpha1

alpha2 =0.67;
beta2 =0.04;
sigma1 = 5.96;
alpha1 =3.03;
miu =0.75;
f = 0.48;
a2=0.1;
a1=0:0.01:0.1;
f1=-(a1.*beta2.*(-a1.^2.*beta2.^2-a2.^2.*alpha2.^2-16.*f^2+(2.*a1*beta2+4.*a1.*miu).^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1.^2)))./(2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2))+...
    a1.*beta2.*sqrt(1-(-a1.^2.*beta2^2-a2.^2.*alpha2.^2-16.*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1^2))./(32.*f.^2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2)))-...
   ((4.*f.*a2.*alpha2.*sqrt(1-(-a1.^2.*beta2.^2-a2.^2.*alpha2.^2-16.*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1^2))/(32.*f.^2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2)))))/sqrt(a1.^2.*beta2^2+a2.^2.*alpha2.^2)-...
    a1.*alpha2.*(-a1.^2.*beta2.^2-a2.^2.*alpha2.^2-16.*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1.^2))./4.*f.*sqrt((2*(a1.^2.*beta2^2+a2.^2.*alpha2.^2)))*...
    sqrt(1-(-a1.^2*beta2.^2-a2.^2.*alpha2.^2-16*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1.^2))./(32.*f^2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2)))-2.*a1.*beta2-4.*a1.*miu ;
f2=-(a1.*beta2.*(-a1.^2.*beta2.^2-a2.^2.*alpha2.^2-16.*f.^2+(2.*a1.*beta2+4.*a1.*miu).^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1.^2)))/(2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2))-...
    a1.*beta2.*sqrt(1-(-a1.^2.*beta2.^2-a2.^2.*alpha2.^2-16.*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1^2))/(32.*f.^2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2)))-...
    ((4*f*a2*alpha2*sqrt(1-(-a1.^2.*beta2.^2-a2.^2.*alpha2.^2-16.*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1^2))/(32.*f.^2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2)))))/sqrt(a1.^2.*beta2^2+a2.^2.*alpha2.^2)+...
    a1.*alpha2.*(-a1.^2.*beta2.^2-a2.^2.*alpha2.^2-16.*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1.^2))/4.*f.*sqrt((2*(a1.^2.*beta2^2+a2.^2.*alpha2.^2)))*...
   sqrt(1-(-a1.^2*beta2.^2-a2.^2.*alpha2.^2-16*f.^2+(2.*a1.*beta2+4.*a1.*miu)^2+(-3.*a1.^3.*alpha1-4.*a1.*sigma1.^2))/(32.*f^2.*(a1.^2.*beta2.^2+a2.^2.*alpha2.^2)))-2.*a1.*beta2-4.*a1.*miu ;
      
figure(1)
hold on
plot(a1 ,f1)
plot(a2,f2)
报错是Error using ==> mpower
Matrix must be square.
我应经矩阵相乘、乘方的地方加“.”了 不知道为什么?

ChaChing 发表于 2011-5-28 12:38

本帖最后由 ChaChing 于 2011-5-28 16:02 编辑

Ref: 10F, 常见的程序出错问题整理 http://forum.vibunion.com/thread-46001-1-1.html
from http://forum.vibunion.com/home-space-uid-63979-do-blog-id-18250.html

还有式子那麼长, 我想别人会懒得检查, 建议LZ可以分段逐步执行看看, 比较容易侦错


lihaitao123 发表于 2011-5-28 13:52

多谢,经过分段检查后,问题已经解决,可以做出图了。
但我现在想做出,a1,a2之间关系图,那样就得把f1,f2看成定值,这样就用到了隐函数作图了。想用ezplot试一下。

lihaitao123 发表于 2011-5-28 15:28

这是我刚做的a1。a2的关系图。a1和a2是两个相互耦合的振幅
但是,里面有好几条线,不知道,该看那一条啊!

ChaChing 发表于 2011-5-28 16:25

lihaitao123 发表于 2011-5-28 15:28 static/image/common/back.gif
这是我刚做的a1。a2的关系图。a1和a2是两个相互耦合的振幅
但是,里面有好几条线,不知道,该看那一条啊! ...

可能太专业了, 水平有限, 看不清LZ问什麼了!?

zhouyang664 发表于 2011-5-29 18:06

这个啥叫“相互耦合的振幅”?问错板块了吧?呵呵
页: [1]
查看完整版本: 作图出现的问题:Matrix must be square?