Filter löschen
Filter löschen

Error: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

1 Ansicht (letzte 30 Tage)
The function runs until the first deltat limit is satisfied then errors out while the other 3 deltat elements still need to run. Is there a way to fix this? Thank you.
function output=conedepth(y0)
rtop=2.5;ytop=4;yout=1;s=ytop/rtop; %initial conditions/constant conditions
deltat=[1,0.5,0.1,0.05]; day=10;
for k=1:4
n=day./deltat
y=y0;t=0; %starting level of water
for i=1:n
V=pi*y.^3/(3*s^2);
if y>=yout
delV=3*(sin(t).^2)-3*(y-yout).^1.5;
else
delV=(3*(sin(t).^2));
end
V=V+delV
y=(3*V*s^2/pi).^(1/3)
t=t+deltat;
end
VV(k,i)=V
yy(k,i)=y
tt(k,i)=t
end
end

Antworten (1)

Viren Gupta
Viren Gupta am 25 Okt. 2018
The error arises at the line
VV(k,i)=V
From 'VV(k,i)' , MATLAB assumes that VV is an array/matrix. V is already a vector. Hence an element of VV must be a scalar component not a vector/array.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by