Best way to store a variable outside of a loop

조회 수: 3 (최근 30일)
A
A 2013년 1월 28일
Hello!
I have a program that runs through a series of images, which are called upon by iterating the number at the end of the file name, ex:
path=('E:\Dropbox\Zeeman data 1\');
for i=[1,5,11];
filename=([path 'IMG_' num2str(file(1,i)) '.jpg']);
...
end
In this for loop, I am finding the location of the peaks of resultant intensity profiles, using the function
[pks,locs]=findpeaks(a, 'MINPEAKHEIGHT', 10);
The trouble is, that this value is overwritten each time that I go through the loop, and I would like to have these values visible for each iteration, ie file1, file5 and file11, when I exit the loop.
How can I rename the 'locs' parameter for each iteration so that I can have access to it after the routine is done?
Thank you!
  댓글 수: 1
Jan
Jan 2013년 1월 28일
Btw, do not shadow the important function "path" by a local variable.

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

답변 (1개)

Sean de Wolski
Sean de Wolski 2013년 1월 28일
[pks(i), locs(i)] = findpeaks(etc.)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by