필터 지우기
필터 지우기

combining variables into one variable

조회 수: 9 (최근 30일)
Janis
Janis 2014년 8월 21일
답변: Michael Haderlein 2014년 8월 21일
How to combine several variables into one variable? I have 28 variables with the same amount of data (tables 125x121) and I want to transform that into a one variable. Each variable is 125x121 double. I want to combine them all and get 28x125x121 double. How can I do that?

채택된 답변

Michael Haderlein
Michael Haderlein 2014년 8월 21일
I'd like to throw the cat function into the discussion:
X=cat(3,S000_010,S010_S020,...);
To your question in the comment on David Sanchez answer: You have a comma too much in your parenthesis and the first = doesn't make sense. It should be X(1,:,:)=S000...
Best regards, Michael

추가 답변 (1개)

David Sanchez
David Sanchez 2014년 8월 21일
편집: David Sanchez 2014년 8월 21일
your_Combination = zeros(28,125,121); % initialize the final variable
Now you have several options depending on your data:
your_Combination = (1,:,:,) = table_1;
your_Combination = (2,:,:,) = table_2;
...
and so on
You could do it in a for-loop in case your tables allow it:
for k = 1:28
your_Combination = (k,:,:,) = table(k);
end
It all depends on the format of your tables.
  댓글 수: 1
Janis
Janis 2014년 8월 21일
Thank you for the answer Each variable is in form of matrix. I'm new to the matlab. is table_1, table_2 etc the name of variable I need to write in the code?
I called the final variable X. Variables I want to add to it are called S000_010; S010_020;.......S270_280.
I made the following code: X = (1,:,:,) = S000_010;X = (2,:,:,) = S010_S020;........... and got an error: Error: Expression or statement is incorrect--possibly unbalanced (, {, or [. What's wrong there

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by