I have a multidimensional variable SC (1x1x104) which is storage capacity for a region from 2004 to 2012. I want to subtract current cell values from previous values so I can get a whole new variable TSC. I tried using the for loop code below but it didn't give the desired result. I hope someone can help with this. Thanks!
for t=1:length(SC); TSC=SC-(SC(:,:,t)-1)./t; end

답변 (1개)

KSSV
KSSV 2018년 7월 18일

1 개 추천

TSC = cell(1,103) ;
for i = 1:103
TSC{i} = SC{1,1,i}-SC{1,1,i+1} ;
end

댓글 수: 3

Dorcas Oluwabimpe Idowu
Dorcas Oluwabimpe Idowu 2018년 7월 18일
편집: Dorcas Oluwabimpe Idowu 2018년 7월 18일
Hi, I ran the code and got this error message,
Cell contents reference from a non-cell array object. Is there something I ought to have done?
@Dorcas Oluwabimpe Idowu: your question clearly states that you have cells of a cell array, and so KSSV's answer gives you a solution for cell arrays. But apparently actually you don't have a cell array at all, probably you have a numeric array. Please show us the output of this command:
whos SC
Dorcas Oluwabimpe Idowu
Dorcas Oluwabimpe Idowu 2018년 7월 19일
I'm sorry about the mix up in my question. Actually, what I want to achieve is to solve this equation;
TSC=SC(t)-SC(t-1)/change in t.
The SC file is a multidimensional matrix with lat, lon and time dimensions.
I have attached the output of the command in my previous question to this question.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2018년 7월 17일

댓글:

2018년 7월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by