How can I loop this to make it go automatically?

3 views (last 30 days)
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 Comments
Steven Lord
Steven Lord on 5 Jan 2024
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 on 6 Jan 2024
The question, imo, should be - Why do you want to do this? What is the objective?

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!