Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

I have four 1x50 matrices and I want to save them to one 4x50 matrix. How can I do this?

Asked by Teemu

Teemu (view profile)

on 5 Feb 2013

I have four 1x50 matrices and I want to save them to one 4x50 matrix. How can I do this?

2 Comments

Cedric Wannaz

Cedric Wannaz (view profile)

on 5 Feb 2013

You deleted the content of all the 4 questions that you asked, after people spent time and energy answering/commenting them, why?

Jan Simon

Jan Simon (view profile)

on 5 Feb 2013

@Teemu: I strongly suggest, that you ask the admins to restore your question. Otherwise there is the chance, that the contributors will ignore your questions in the future, because they could assume, that you are not serious. You find the address at the bottom of this page or you can ask randy Souza. Thanks.

Teemu

Teemu (view profile)

Products

No products are associated with this question.

3 Answers

Answer by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 5 Feb 2013
Edited by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 5 Feb 2013
Accepted answer
for k=1:50
   title{k}=sprintf('title%d',k)
end
a=rand(1,50);
b=rand(1,50);
c=rand(1,50);
d=rand(1,50);
M=[title;num2cell(a);num2cell(b);num2cell(c);num2cell(d)]

3 Comments

Teemu

Teemu (view profile)

on 5 Feb 2013

It´s not working.

for k=1:50
 title{k}=sprintf('title%d',k)
end
a=rand(1,50);
b=rand(1,50);
c=rand(1,50);
d=rand(1,50);
M=[title;num2cell(a);num2cell(b);num2cell(c);num2cell(d)]
??? Cell contents assignment to a non-cell array object.
Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 5 Feb 2013

Try again, but before, type: clear

clear
for k=1:50
titre{k}=sprintf('title%d',k)
end
a=rand(1,50);
b=rand(1,50);
c=rand(1,50);
d=rand(1,50);
M=[titre;num2cell(a);num2cell(b);num2cell(c);num2cell(d)]

I've also changed the variable title which is reserved to ploting functions

Teemu

Teemu (view profile)

on 5 Feb 2013

ok, that was the problem, thanks!

Azzi Abdelmalek

Azzi Abdelmalek (view profile)

Answer by Youssef KHMOU

Youssef KHMOU (view profile)

on 5 Feb 2013

Suppose your matrices are A,B,C,D all with size 1x50 :

 M=zeros(4,50);
 M(1,:)=A;
 M(2,:)=B;
 M(3,:)=C;
 M(4,:)=D;

0 Comments

Youssef  KHMOU

Youssef KHMOU (view profile)

Answer by Ryan Livingston

Ryan Livingston (view profile)

on 5 Feb 2013
 A = rand(1,50);
 B = rand(1,50);
 C = rand(1,50);
 D = rand(1,50);
 E = [A;B;C;D];

1 Comment

Teemu

Teemu (view profile)

on 5 Feb 2013

Thanks. How I can add one "tittle" line to 4x50 matrix so it will be 5x50 matrix? The line should be added to first line of the matrix.

Ryan Livingston

Ryan Livingston (view profile)

Contact us