How can I loop this to make it go automatically?

조회 수: 2 (최근 30일)
Lucas
Lucas 2024년 1월 5일
댓글: Dyuman Joshi 2024년 1월 6일
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