i have a mistake named Subscripted assignment dimension mismatch.
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
krillbest=zeros(3,16,q1-1,cn);
for i=1:q1-1
krillbest(:,:,i,1)=bestkrill(:,:,i);
end
please return me immmediately, i have to solve this problem immediately.Thanks for everything
3 Commenti
Risposte (3)
Walter Roberson
il 8 Ago 2015
krillbest=zeros(3,16,q1-1,cn);
krillbest(:,:,:,1) = bestkrill;
If you want bestkrill copied to each of the cn layers then use
krillbest = repmat(bestkrill, 1, 1, 1, cn);
0 Commenti
Walter Roberson
il 8 Ago 2015
Illustration:
q1 = 11;
cn = 5;
bestkrill = rand(3,16,q1-1); %put any data you want here.
krillbest=zeros(3,16,q1-1,cn);
for i=1:q1-1
krillbest(:,:,i,1)=bestkrill(:,:,i);
end
The code from krillbest onwards was copied exactly from your posting, and it works without problem, provided that the size() of the first two dimensions of bestkrill are the same as 3, 16, and that the size of the third dimension of bestkrill is at least as large as q1-1 .
It seems likely to me that in your code, bestkrill is not the size you expect. You need to look at size(bestkrill) and be sure that really does start 3, 16.
At the command line, give the command
dbstop if error
and then run your initial code. When it stops with the error, examine the size() of each of the variables.
Vedere anche
Categorie
Scopri di più su Debugging and Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!