Subscripted assignment dimension mismatch.
Ältere Kommentare anzeigen
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,:);
Akzeptierte Antwort
Weitere Antworten (1)
sxint(3,:) is not a scalar, but the left hand side S(i,1) is a scalar location.
8 Kommentare
Walter Roberson
am 18 Mai 2019
You are looping over several Lv values, running a boundary value problem for each. What would you like plotted from each of those runs?
I suspect you want
S(i,1) = deval(sol, xa, 3);
MINATI
am 18 Mai 2019
Walter Roberson
am 18 Mai 2019
sxint(3) is a scalar. It does not make sense to talk about "all values".
There is no eta defined in your question, so I do not know what f''(eta) refers to.
Perhaps you want
S(i,:)=sxint(3,:);
However if you only want the information for the third time point, xint(3), then it is a waste of time to compute sxint for all the time points, and might as well use
sxint = deval(sol, xint(3));
S(i,:) = sxint;
Matt J
am 18 Mai 2019
@MINATI
So what to do?
You must tell us what the sizes of the left and right hand side of the assigment are intended to be.
MINATI
am 19 Mai 2019
Walter Roberson
am 19 Mai 2019
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
am 19 Mai 2019
Kategorien
Mehr zu Data Exploration finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

