i have a mistake named Subscripted assignment dimension mismatch.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (3)
Walter Roberson
am 8 Aug. 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 Kommentare
Walter Roberson
am 8 Aug. 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.
Siehe auch
Kategorien
Mehr zu Debugging and Analysis 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!