필터 지우기
필터 지우기

Define New Variables Based on Pre-existing One

조회 수: 1 (최근 30일)
Jessica
Jessica 2014년 6월 20일
댓글: Matt J 2014년 6월 20일
I have a variable and want to create more variables based upon it; however, I'm having a hard time coming up with the syntax for it.
Say I have:
total_channels=5 %%Total channels will probably be between 1 and 6 depending on the image I'm processing
I want to create new variables based on this number, so that I can add pixel information into those variable
I'd like the new variables to be channel_1, channel_2, channel_3 etc.
Any help is greatly appreciated

답변 (1개)

Matt J
Matt J 2014년 6월 20일
Better than what you asked for:
channel=cell(1,total_channels);
for i=1:total_channels
channel{i}=...whatever...
end
  댓글 수: 1
Matt J
Matt J 2014년 6월 20일
You could also do If all are the same dimensions, you could also do
for i=total_channels-1:1
channel(:,:,i)=...whatever...
end

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

카테고리

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