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

creating a matrix that contains a struct

Asked by Itzik Ben Shabat on 6 Nov 2012

Hi, I want to create a matrix that contains a struct in the first row. and integers in the next rows for example my matrix can look like this A=[[0,0,0],[0,0,1];1,1;0,1]

is there a way t do this? thanks

0 Comments

Itzik Ben Shabat

Tags

Products

No products are associated with this question.

2 Answers

Answer by Azzi Abdelmalek on 6 Nov 2012
Accepted answer
A={[0,0,0],[0,0,1];1,1;0,1}

1 Comment

Azzi Abdelmalek on 6 Nov 2012
n=10;
m=4;
A=cell(3,n)
for k=1:n
  A{1,k}=rand(1,m)  % eg
  A{2,k}=randi(10,1,1) %eg
  A{3,k}=randi(10,1,1) % eg
end

%doc cell

Azzi Abdelmalek
Answer by Itzik Ben Shabat on 6 Nov 2012

Thank you for your answer but A was just an example of a more general need. say i want to creat a matrix thats 3Xn having a 1Xm array in each cell in the first row. second and third rows get integers. how do i construct this? and how do i initialize it? thanks

0 Comments

Itzik Ben Shabat

Contact us