필터 지우기
필터 지우기

Create workspace file automatically.

조회 수: 1 (최근 30일)
faizal
faizal 2011년 2월 10일
Let's say I have:
a = {'one' 'two' 'three'};
b = [1 2 3];
I want each word create a file in workspace automatically and equal to number. Like:
one=1; two=2; three=3;

채택된 답변

Brett Shoelson
Brett Shoelson 2011년 2월 10일
I think you mean "variable," not "file." Right?
for ii = 1:numel(a)
eval(sprintf('%s = %d',a{ii},b(ii)));
end
Cheers,
Brett
  댓글 수: 2
Brett Shoelson
Brett Shoelson 2011년 2월 10일
(But I agree with Walter.) :)
faizal
faizal 2011년 2월 10일
I accept that

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

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 2월 10일
This is generally considered poor programming and hard to maintain. Please see the FAQ answer on this topic for alternatives.

faizal
faizal 2011년 2월 10일
It works. Thanks.
Yea it was 'variable' not 'file'.
Sorry

카테고리

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