creating a matrix that contains a struct

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

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 6일

0 개 추천

A={[0,0,0],[0,0,1];1,1;0,1}

댓글 수: 1

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 6일
편집: Azzi Abdelmalek 2012년 11월 6일
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

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

추가 답변 (1개)

Itzik Ben Shabat
Itzik Ben Shabat 2012년 11월 6일

0 개 추천

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

카테고리

도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by