Problem w/ saving different parts of a 3D matrix in separate matrices!
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to save different parts of a 3D matrix into separate individual matrices (like different matrices in one single folder). I have written the following but I get the error "Subscripted assignment dimension mismatch"! I believe the problem is the LHS; so I tried different LHS's such as indv_func(:,t), indv_func(), etc. but I keep getting different errors! Could anyone help me with resolving this pls?
for j = 1:100000;
for t = 1:time(j);
indv_func(:,j,t) = func_status(:,j,1:time(j));
end
end
I also get this warning about "preallocating" but I have no idea how to resolve it, so if you have any ideas about that pls let me know too (I wrote this before the for loop but I doubt if it's appropriate!):
indv_func = zeros(size(func_status,1),100000,max(time));
0 Kommentare
Antworten (1)
ANKUR KUMAR
am 21 Dez. 2017
Bearbeitet: ANKUR KUMAR
am 21 Dez. 2017
There are too many things which you have to check before executing the loop.
indv_func(:,j,t) = func_status(:,j,1:time(j));
You are trying to store
_func_status(:,j,1:time(j))_
in some variable. Third dimension is 1:time(j). And at the same time, you are trying to store this in
indv_func(:,j,t)
See, You are trying to store indv_status whose third dimension is more than 1 in the variable indv_func whose third dimension is only 1 (because you have used t in indv_func)
You can resolve your problem by using
indv_func(:,j,t) = func_status(:,j,time(j));
OR
You have to store func_status in the cell because dimension of func_status is changing after every loop.
indv_func{j} = func_status(:,j,1:time(j));
Please attach your complete prog, if the error is still there.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!