i have a mistake named Subscripted assignment dimension mismatch.
5 次查看(过去 30 天)
显示 更早的评论
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 个)
Walter Roberson
2015-8-8
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 个评论
Walter Roberson
2015-8-8
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!