필터 지우기
필터 지우기

How to store loop values into array?

조회 수: 1 (최근 30일)
uic
uic 2014년 12월 17일
댓글: Stephen23 2014년 12월 17일
Hi all :
This is my code :
for i=1:3689 b=bret(1,10000*q(i,1)-9999:10000*q(i,1)) sel=(max(b)-min(b))/3.3 y=peakfinder(b,sel) p=size(y,2) for j=1:p-1 v(1,j)=((y(1,j+1)-y(1,j))) end; * SYNTAX REQUIRED * end;
In the above loop, I get arrays of random size for the value V. I want all these arrays to be stored in one single array. To pre allocate memory, I donot know the size of the arrays which are being generated. Kindly Help.!
  댓글 수: 1
Stephen23
Stephen23 2014년 12월 17일
Please edit your question and use the {} Code button above the text box to format your code, and make it more readable.
Note you should not use i as your loop variable, as this is the name of the inbuilt function for the imaginary unit .

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

답변 (1개)

Thorsten
Thorsten 2014년 12월 17일
You can use cell arrays to store variables of different sizes. Like
V{i}(j)= y(j+1) - y(j);
And something is probably wrong with your code, since the inner loop does not depend on i.
  댓글 수: 1
uic
uic 2014년 12월 17일
Inner loop doesn't rely on value of 'I'. It depends on the size of 'P'. I want to store the values i get in the inner loop into an array continuously. The above code didn't work.

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by