Subscripted assignment dimension mismatch
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I got an error saying "Subscripted assignment dimension mismatch"
I have this:
clc
clear all
global Mw M0 H rho g theta sigma dt A Rmax
Mw=0.001; M0=0.001; H=0.1; rho=200; g=10;
cos(theta)=0.1; sigma=0.03; dt=0.0004; A=0.00005;Rmax=0.001;
Vtotal=A*H;
for i=1:20
iter=1;
Vvoid=0;
porosity=0;
while porosity < 0.2
R(iter)=Rmax*rand(1);
Vvoid= Vvoid + pi*(R(iter)^2)*H;
porosity=Vvoid/Vtotal;
iter=iter+1;
end
Z=zeros(iter-1,2001);
for t=2:2001
sum=0; sum1=0;
for k=1:iter-1
[Z(k,t)]=Zcalculator(R(k),Z(k,t-1));
sum = sum + pi*(R(k)^2)*Z(k,t);
sum1 = sum1 + pi*(R(k)^2)*H;
end
recovery(i,t)=100*(sum/sum1);
end
end
&&&&&& and my error reads as follows::
??? Subscripted assignment dimension mismatch.
Error in ==> GroupProject at 29
[Z(k,t)]=Zcalculator(R(k),Z(k,t-1));
% does anyone know what is going on???
Réponses (1)
Geoff
le 3 Mai 2012
Enter the command:
dbstop if error
Now run your script and wait for it to break.
Then, in the command window, execute the line:
Zcalculator(R(k),Z(k,t-1));
Is it a scalar? Probably not. You are assigning to Z(k,t), which expects a scalar (because you are asking MatLab to put a value into a single element of Z).
By the way, you don't need to put square brackets around Z(k,t) when you do the assignment.
0 commentaires
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!