声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1411|回复: 5

[编程技巧] 作图出现的问题:Matrix must be square?

[复制链接]
发表于 2011-5-28 12:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
clear all
clc;
syms a1 a2  beta2 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.
我应经矩阵相乘、乘方的地方加“.”了 不知道为什么?

回复
分享到:

使用道具 举报

发表于 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可以分段逐步执行看看, 比较容易侦错


 楼主| 发表于 2011-5-28 13:52 | 显示全部楼层
多谢,经过分段检查后,问题已经解决,可以做出图了。
但我现在想做出,a1,a2之间关系图,那样就得把f1,f2看成定值,这样就用到了隐函数作图了。想用ezplot试一下。
 楼主| 发表于 2011-5-28 15:28 | 显示全部楼层
这是我刚做的a1。a2的关系图。a1和a2是两个相互耦合的振幅
但是,里面有好几条线,不知道,该看那一条啊!
图形3.png
发表于 2011-5-28 16:25 | 显示全部楼层

可能太专业了, 水平有限, 看不清LZ问什麼了!?
发表于 2011-5-29 18:06 | 显示全部楼层
这个啥叫“相互耦合的振幅”?问错板块了吧?呵呵
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-29 09:23 , Processed in 0.076028 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表