How can I loop this to make it go automatically?

3 次查看(过去 30 天)
I can not find how to do this automatically.. Can Anybody help me with this?
StrideDurationlg_9 = (EventData(1:4).StrideDuration);
StrideDurationtm_9 = (EventData(5).StrideDuration);
StrideDurationlg_10 = (EventData(6:10).StrideDuration);
StrideDurationtm_10 = (EventData(11).StrideDuration);
StrideDurationlg_11 = (EventData(12:18).StrideDuration);
StrideDurationtm_11 = (EventData(19).StrideDuration);
StrideDurationlg_12 = (EventData(20:24).StrideDuration);
StrideDurationtm_12 = (EventData(25).StrideDuration);
StrideDurationlg_13 = (EventData(26:30).StrideDuration);
StrideDurationtm_13 = (EventData(31).StrideDuration);
StrideDurationlg_14 = (EventData(32:36).StrideDuration);
StrideDurationtm_14 = (EventData(37).StrideDuration);
StrideDurationlg_16 = (EventData(38:43).StrideDuration);
StrideDurationtm_16 = (EventData(44).StrideDuration);
  3 个评论
Steven Lord
Steven Lord 2024-1-5
Can you dynamically create variables with numbered names like StrideDurationlg_9, StrideDurationtm_9, StrideDurationlg_10, etc.? Yes.
Should you do this? The general consensus is no. That Answers post explains why this is generally discouraged and offers several alternative approaches.
But I agree with @Torsten that there is no pattern I can see in how much data gets put into each variable.
Dyuman Joshi
Dyuman Joshi 2024-1-6
The question, imo, should be - Why do you want to do this? What is the objective?

请先登录,再进行评论。

回答(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