필터 지우기
필터 지우기

How to read multiple files from matlab workspace?

조회 수: 5 (최근 30일)
Khan Muhammad Adeel Khan
Khan Muhammad Adeel Khan 2021년 7월 21일
댓글: Rik 2021년 7월 21일
I have multiple files (sub1, sub2, sub3......subn) in matlab workspace and wants to apply a loop to extract the features. There is error in the code. Kindly guide me to fix this issue. My code is as follow:
s=43;
theta=[ ];
% numsubjects = length(sub);
for sub_i=1:s
subject = sub(str(sub_i));
theta1=mean(subject(3:7,26,:));
theta=[theta,theta1];
end
  댓글 수: 2
KSSV
KSSV 2021년 7월 21일
files or variables?
Khan Muhammad Adeel Khan
Khan Muhammad Adeel Khan 2021년 7월 21일
Thanks for the reply! It's variables from the workspace

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

답변 (1개)

Walter Roberson
Walter Roberson 2021년 7월 21일
Don't do that. Do not allow them to be created into different variables in the first place, and then you will not have to hack to dynamically create variable names.
  댓글 수: 2
Khan Muhammad Adeel Khan
Khan Muhammad Adeel Khan 2021년 7월 21일
Thanks for the feedback. I already have all these files (sub1,sub2....sub43) in matlab workspace. Now I want to extract features from these files. I need to apply loop to extract all the features.
Rik
Rik 2021년 7월 21일
Then you need to change how you get them in your workspace. You're forcing yourself to write terrible code. Why would you do that for no good reason?

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

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by