For loop to iterate over cell data and graph it

조회 수: 4 (최근 30일)
Nikolay N Valov
Nikolay N Valov 2018년 7월 30일
댓글: Nikolay N Valov 2018년 7월 31일
Issue: For loop does not iterate over the entire cell array which I unfortunately can't attach because of how big it is. I am not entirely sure how to fix it, but I feel like the issue might be within the placement of the loop counter. However, even after moving it around, it only shows the 1st or 63rd trial. I don't want to concatenate because if figuring this for loop out would save a lot of time for the rest of the data analysis. Any input would be greatly appreciated.
n = 1;
figure(4),cla
for i = n
plot(hEMcell{n},vEMcell{n},'k')
title('All Trials')
axis tight
axis square
n=n+1;
hold on
end

채택된 답변

Adam Danz
Adam Danz 2018년 7월 30일
편집: Adam Danz 2018년 7월 30일
A for-loop usually operates on a vector of 'i' values whereas you are only looping once
for i = n %where n = 1
You can add n = n+1 but that won't change the fact that the for-loop is already satisfied at the end of the first iteration.
It's not clear how many iterations you expect. If you're looping over every element of 'hEMcell', get rid of 'n' and do this
for i = 1:length(hEMcell)
...
end
  댓글 수: 1
Nikolay N Valov
Nikolay N Valov 2018년 7월 31일
Thank you so much. Honestly, I completely blanked while I was writing this. Very silly mistake. Thank you.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by