필터 지우기
필터 지우기

Vary numbers i a textline

조회 수: 1 (최근 30일)
Johan
Johan 2012년 6월 4일
Hi! I'm trying to write a for-loop that vary numbers in the following code
z(1,:)=TC_Front_1.signals.values;
z(2,:)=TC_Front_2.signals.values;
z(3,:)=TC_Front_3.signals.values;
z(4,:)=TC_Front_4.signals.values;
...
z(n,:)=TC_Front_n.signals.values;
My questions is:
  1. How do I do when I want to search for the first part 'TC_Front_' so I can se how many there is
  2. How do I write to vary the numbers, like in a for-loop with indexes?
Johan
  댓글 수: 3
Johan
Johan 2012년 6월 4일
The values ar from a .mat file and and in the workspacce is it presented as <1x1>struct, how do you men that I should use eval?
BR
Johan
Oleg Komarov
Oleg Komarov 2012년 6월 4일
I never said to use eval(), see Walter's answer.

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 6월 4일
for jj = 1:n
z(jj,:) = eval(['TC_Front_',num2str(jj),'.signals.values']);
end

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 6월 4일
If the values are coming from a .mat file then use the form of load() that assigns the inputs to a structure; then you can use dynamic field names.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by