Operator '.^' is not supported for operands of type 'cell'
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I wanted to plot lambda which is defined in the code below, but it has an error: Operator '.^' is not supported for operands of type 'cell'.
Could you please tell me how solve this problem and plot lambda?
vplc=0.25;delta=2.5;tau_max=44000;Ktau=0.045;
kc=0.1; kh=0.05;Vp=0.9;K=0.000015;kp=0.15;gamma=5.5;kb=0.4;vss=0.044;
Vpm=0.000159;Kpm=0.15;alpha0=.00000681;alpha1=0.0000227;Ke=7;Vs=0.002;ks=0.1;
Kf=0.18;kplc=0.055;ki=2;gamma=5.5;kipr=0.18;
[c,ct]=meshgrid(0:0.005:1);
p=(vplc./ki).*(c.^2./((kplc).^2+c.^2));
A=(-(vss.*c.^2)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(Ktau.^4.*ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^{4}));
h=(-2.*Kc.^2.*Kp^2.*A)./(5.*c.^4.*ct.*gamma.*Kf.*p.^2.*((a.*A)./(5.*ct.*gamma.*Kf))-1);
Po=(p.^2.*c.^4.*h)./(kb.*p.^2.*c.^4.*h+kb.*kp.^2.*kc.^2);
lambda=Kf.*gamma.*ct.*((10.*c.^3.*p.^2.*h.*(c.^4*p.^2.*h+kp.^2.*kc.^2-c.^4.*p.^2.*h))./(c.^4*p.^2.*h+kp.^2.*kc.^2).^2)-(2.*vss.*c/ks.^2);
surf(c,ct,lambda);
댓글 수: 0
채택된 답변
Star Strider
2022년 8월 1일
The original problem was caused by using curly brackets {} around the 4:
A=(-(vss.*c.^2)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(Ktau.^4.*ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^{4}))
↑ ↑ ← HERE
Also, MATLAB is case-sensitive, so ka~=Ka, a~=A and other instances.
Also, please make your code easier to read. Bunching up several assignments does not make the code more efficient (it might make it less efficient), and it definitely does make it more difficult to read and troubleshoot.
With those (and similar) corrections, this is the result —
vplc=0.25;
delta=2.5;
tau_max=44000;
Ktau=0.045;
Kc=0.1;
kh=0.05;
Vp=0.9;
K=0.000015;
Kp=0.15;
gamma=5.5;
kb=0.4;
vss=0.044;
Vpm=0.000159;
Kpm=0.15;
alpha0=.00000681;
alpha1=0.0000227;
Ke=7;
Vs=0.002;
ks=0.1;
Kf=0.18;
kplc=0.055;
ki=2;
gamma=5.5;
kipr=0.18;
[c,ct]=meshgrid(0:0.005:1);
p=(vplc./ki).*(c.^2./((kplc).^2+c.^2));
A=(-(vss.*c.^2)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(Ktau.^4.*ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
h=(-2.*Kc.^2.*Kp^2.*A)./(5.*c.^4.*ct.*gamma.*Kf.*p.^2.*((A.*A)./(5.*ct.*gamma.*Kf))-1);
Po=(p.^2.*c.^4.*h)./(kb.*p.^2.*c.^4.*h+kb.*Kp.^2.*Kc.^2);
lambda=Kf.*gamma.*ct.*((10.*c.^3.*p.^2.*h.*(c.^4*p.^2.*h+Kp.^2.*Kc.^2-c.^4.*p.^2.*h))./(c.^4*p.^2.*h+Kp.^2.*Kc.^2).^2)-(2.*vss.*c/ks.^2);
figure
surf(c,ct,lambda, 'EdgeColor','none')
I have no idea what you are doing, so I defer to you for whatever else needs to be done to get a reasonable result.
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!