Vary numbers i a textline
1 次查看(过去 30 天)
显示 更早的评论
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:
- How do I do when I want to search for the first part 'TC_Front_' so I can se how many there is
- How do I write to vary the numbers, like in a for-loop with indexes?
Johan
3 个评论
采纳的回答
Andrei Bobrov
2012-6-4
for jj = 1:n
z(jj,:) = eval(['TC_Front_',num2str(jj),'.signals.values']);
end
0 个评论
更多回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!