Save values of variable inside loop

조회 수: 1 (최근 30일)
Martiningrum Dyah Rahayu
Martiningrum Dyah Rahayu 2016년 11월 16일
댓글: Martiningrum Dyah Rahayu 2016년 11월 16일
Can anyone help me to save values of 'hFMar10(k)', where k is 31 times iteration. So I will have a file that contain [hFMar10(1), hFMar10(2), hFMar10(3),.......,hFMar10(31)] Below is my code :
load CP_Max10;
x=[1:1:186];
%Max from raw data directly
y1=CP_Max10(:,1);
NData1=length(y1);
k=0;
figure(1);
for n=1:6:NData1
k=k+1;
hFMar10(k)=plot(y1(n:n+5), 'linewidth',2);
hold on
end
  댓글 수: 4
KSSV
KSSV 2016년 11월 16일
All ready they are saved in CP_Max10. Why you want to save them again?
Martiningrum Dyah Rahayu
Martiningrum Dyah Rahayu 2016년 11월 16일
Sorry, I forgot to say that for every line I have to pick maximum value an then save it.

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

채택된 답변

KSSV
KSSV 2016년 11월 16일
load CP_Max10;
x=[1:1:186];
%Max from raw data directly
y1=CP_Max10(:,1);
NData1=length(y1);
k=0;
figure(1);
for n=1:6:NData1
k=k+1;
hFMar10(k)=plot(y1(n:n+5), 'linewidth',2);
iwant{k} = max(y1(n:n+5)) ;
hold on
end
if size of CP_Max10 is known, the desired value can be initialized. You have maximum values in a cell array iwant. This can be saved using save. doc save.
  댓글 수: 1
Martiningrum Dyah Rahayu
Martiningrum Dyah Rahayu 2016년 11월 16일
Thank you so much KSSV...
That's all what I need

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by