Example:
for i=1:n X=DATA1(i,1); Y=DATA2{1,i}; Z=X-Y;
end
what I want is that it saves the data to Z, summing them, so, for i=1 , Z=[1 2 3 4 5], for i=2 Z becomes Z=[1 2 3 4 5 6 7] etc.
so i need to do something with Z but dont know what. currently it only shows the result of the last i.

댓글 수: 2

Image Analyst
Image Analyst 2012년 12월 14일
Do you really have X as a numerical array (double, etc.) and Y as a cell array???
Hello kity
Hello kity 2012년 12월 14일
yes x= column full of values (nummerical array) and Y cells , with each cell with diff lengths

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

 채택된 답변

Pedro Villena
Pedro Villena 2012년 12월 14일
편집: Pedro Villena 2012년 12월 14일

0 개 추천

for i=1:n,
X = DATA1(i,1); %%DATA1 is an array
Y = DATA2{i,1}; %%DATA2 is a cell
Z(i,:) = X-Y;
end
save Z
or
Z = DATA1 + cell2mat(DATA2);
save Z

댓글 수: 1

Hello kity
Hello kity 2012년 12월 14일
the first one works if both X and Y are matrix ( ()) but if Y is cell array {} then it gives trouble. Somehow I need to convert Y to matrix then put it in the equation.
I look into the second tip
thank you

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

추가 답변 (0개)

카테고리

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

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by