qq_36509480
qq_36509480
2020-07-03 23:13
采纳率: 0%
浏览 678

在MATLAB中解带参数方程组并画图

1.给参数赋值,再解六元一次方程组,分别画出ratio与其中两个解C11、C12的图像,以及表达式g2=2*C12^2/C11^4的图像。图片说明

clc
close all
clear all 

syms C11 C12 C20 C21 C30 C31
g = 2*pi*4;
Omega1 = 2*pi*1.3;
Omega2 = 2*pi*1.5;
gamma31 = 2*pi*3;
gamma21 = 2*pi*0.3;
k = 2*pi*4;
E = 2*pi*0.01;
delta2=2*pi*0;
fi=pi*0;
ratio = -50:0.001:50;  %横坐标从-50到50取1000个点
for ii=1:length(ratio)
    delta1(ii) =2*pi*ratio(ii);
    deltam(ii) = delta1(ii);
    ff1 = E*C11+Omega1*C20;    %六个方程组
    ff2 = E+(deltam(ii)-1i*k)*C11+E*sqrt(2)*C12+Omega1*C21+g*C30;
    ff3 = sqrt(2)*E*C11+(deltam(ii)-1i*k)*C12+sqrt(2)*g*C21;
    ff4 = C11*Omega1+E*C20+(deltam(ii)+delta1(ii)-1i*k-1i*gamma21)*C21+Omega2*C31;
    ff5 = C11*g+Omega2*C20*exp(-1i*fi)+(delta1(ii)+delta2-1i*gamma31)*C30+E*C31;
    ff6 = sqrt(2)*g*C12+Omega2*C21*exp(-1i*fi)+E*C30+(deltam(ii)-1i*k+delta1(ii)+delta2-1i*gamma31)*C31;

    [C11,C12,C20,C21,C30,C31] = solve(ff1,ff2,ff3,ff4,ff5,ff6); %解方程
    C11 = vpa(C11,4);    %得到方程的解C11
    C12 = vpa(C12,4);     %得到方程的解C12
    CC11(ii,:) = double(C11);
    CC12(ii,:) = double(C12);
    g2(ii) = 2*(abs(CC11(ii,:)))^2/(abs(CC12(ii,:)))^4;   %表达式g2=2*|C12|^2/|C11|^4
end
plot(ratio,CC11,'r',ratio,CC12,'b',ratio,g2,'g') %画出ratio与C11和C12以及g2的函数图像


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • weixin_43413649
    不不不卟 2020-07-04 14:53

    你那个C11和C12,在循环里(解方程)赋值了,也就是原本是符号变量的C11和C12被你赋值了,在第二步当然解不出来,把符号变量C11、C12和赋值的C11、C12分开 。
    (刚来这不久,发现回答得在这里,尴尬)

    点赞 评论

相关推荐