필터 지우기
필터 지우기

How can I change the name of my vector of each iteration?

조회 수: 3 (최근 30일)
Mariana
Mariana 2014년 7월 11일
댓글: Mariana 2014년 7월 11일
Hello everyone
I have this code that generates a vector (different length in each iteration). I called it SEC1 cause I thought I could find a way to make the 1 run with the i value, but I can't. What can I do?
Thanks for the help.
n = length(S);
for ii = 1:n;
a = M(ii,1);
b = M(ii,2);
SEC1 = unique(IdD(a:b));
end

채택된 답변

David Sanchez
David Sanchez 2014년 7월 11일
Use eval:
S = rand(3,1); % sample data to test the script
n = length(S);
for ii = 1:n;
a = M(ii,1);
b = M(ii,2);
array_name = sprintf('SEC%g = unique(IdD(a:b))',ii);
eval(array_name);
end
go to eval documentation for more information about the function
help eval
doc eval
  댓글 수: 1
Mariana
Mariana 2014년 7월 11일
I was trying similar things for hours and couldn't make it work.
Thanks a lot!!

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by