필터 지우기
필터 지우기

Problem w/ saving different parts of a 3D matrix in separate matrices!

조회 수: 2 (최근 30일)
Antonio
Antonio 2017년 12월 21일
편집: ANKUR KUMAR 2017년 12월 21일
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));

답변 (1개)

ANKUR KUMAR
ANKUR KUMAR 2017년 12월 21일
편집: ANKUR KUMAR 2017년 12월 21일
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.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by