Subscripted assignment dimension mismatch.

조회 수: 6 (최근 30일)
MINATI
MINATI 2019년 5월 18일
댓글: Walter Roberson 2019년 5월 20일
function main
D=1; %L=0;
Pr=1;R=0.1;Sc=1;
xa=0;xb=6;
Lv = [-2.5:0.025:0];
p = [];
for i=1:length(Lv)
L = Lv(i);
fODE = @(x,y) [y(2); y(3); y(2)^2-y(3)*y(1)-1; y(5); -3*Pr*y(1)*y(5)/(3+4*R); y(7); -Sc*y(1)*y(7)];
BCres= @(ya,yb)[ya(1); ya(2)-L-D*ya(3); ya(4)-1; ya(6)-1; yb(2)-1; yb(4);yb(6)];
xint=linspace(xa,xb,101);
solinit=bvpinit(xint,[0 1 0 1 0 1 0]);
sol=bvp4c(fODE,BCres,solinit);
sxint=deval(sol,xint);
%%WE NEED TO PLOT for
S(i,1)=sxint(3,:);
end
figure(1)
plot(Lv,S,'-','Linewidth',1.5);
xlabel('\bf \lambda');
ylabel('\bf C_{f}');
hold on
end
%%While running the code following ERROR occurs:
Subscripted assignment dimension mismatch.
Error in (line 17)
S(i,1)=sxint(3,:);

채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 19일
function all_sxint = main
D=1; %L=0;
Pr=1; R=0.1; Sc=1;
xa=0;xb=6;
Lv = [-2.5:0.025:0];
nLv = length(Lv);
all_sxint = cell(nLv, 1);
S = zeros(nLv, 7);
for i=1:nLv
L = Lv(i);
fODE = @(x,y) [y(2); y(3); y(2)^2-y(3)*y(1)-1; y(5); -3*Pr*y(1)*y(5)/(3+4*R); y(7); -Sc*y(1)*y(7)];
BCres= @(ya,yb)[ya(1); ya(2)-L-D*ya(3); ya(4)-1; ya(6)-1; yb(2)-1; yb(4);yb(6)];
xint=linspace(xa,xb,101);
solinit=bvpinit(xint,[0 1 0 1 0 1 0]);
sol=bvp4c(fODE,BCres,solinit);
sxint=deval(sol,xint);
all_sxint{i} = sxint;
S(i,:) = sxint(3,:);
end
figure(1)
plot(Lv, S, '-', 'Linewidth', 1.5);
xlabel('\bf \lambda');
ylabel('\bf C_{f}');
legend({'bc1', 'bc2', 'bc3', 'bc4', 'bc5', 'bc6', 'bc7'})
end
Assign the output to a variable so that you can examine all of the time points for all of the Lv values afterwards, as you indicate that you need to be able to do that.
  댓글 수: 11
MINATI
MINATI 2019년 5월 20일
No we cant go beyond \lambda = - 2
Walter Roberson
Walter Roberson 2019년 5월 20일
Lv = [-2.5:0.025:0]; is in your existing code

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2019년 5월 18일
편집: Matt J 2019년 5월 18일
sxint(3,:) is not a scalar, but the left hand side S(i,1) is a scalar location.
  댓글 수: 8
Walter Roberson
Walter Roberson 2019년 5월 19일
Is there a reason you need to calculate at all of the time points, and then to store data for only the third time point? Is there a particular reason why my suggestion to calculate only at the third time point will not work for you?
MINATI
MINATI 2019년 5월 19일
Yes, Actually I need to validate a previous study with mine but unable. Since they have drawn with all points, I am trying in that way.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by