请教Matlab元胞数组的问题:
t:=1:100用a=cell(1,100)和a{1,1}=[sin(t),cos(t),0;cos(t),0,0;0,0,0]来定义其中的一个元素{1,1}.但是怎么批...
t:=1:100
用 a=cell(1,100) 和 a{1,1} =[sin(t),cos(t),0;cos(t),0,0;0,0,0] 来定义其中的一个元素{1,1}. 但是怎么批量的定义全部100个元素?
还有,显示a值的时候是[3x3 double]? 怎样能显示全部的元素?
多谢啦
尝试用 a{1,:}=rand(3) 这样的句子,但是出错,
提示:
The right hand side of this assignment has too few values to satisfy
the left hand side.
应该怎么实现呢? 展开
用 a=cell(1,100) 和 a{1,1} =[sin(t),cos(t),0;cos(t),0,0;0,0,0] 来定义其中的一个元素{1,1}. 但是怎么批量的定义全部100个元素?
还有,显示a值的时候是[3x3 double]? 怎样能显示全部的元素?
多谢啦
尝试用 a{1,:}=rand(3) 这样的句子,但是出错,
提示:
The right hand side of this assignment has too few values to satisfy
the left hand side.
应该怎么实现呢? 展开
2个回答
展开全部
批量赋值貌似不能通过引用内容实现,引用数组元素还是可以的~
>> a=cell(3,3)
a =
[] [] []
[] [] []
[] [] []
>> a(:,:)={2}
a =
[2] [2] [2]
[2] [2] [2]
[2] [2] [2]
另外:
>> a(:,:)=num2cell(rand(3,3))
a =
[0.9649] [0.9572] [0.1419]
[0.1576] [0.4854] [0.4218]
[0.9706] [0.8003] [0.9157]
>> a(:,:)={rand(3,3)}
a =
[3x3 double] [3x3 double] [3x3 double]
[3x3 double] [3x3 double] [3x3 double]
[3x3 double] [3x3 double] [3x3 double]
>> a=cell(3,3)
a =
[] [] []
[] [] []
[] [] []
>> a(:,:)={2}
a =
[2] [2] [2]
[2] [2] [2]
[2] [2] [2]
另外:
>> a(:,:)=num2cell(rand(3,3))
a =
[0.9649] [0.9572] [0.1419]
[0.1576] [0.4854] [0.4218]
[0.9706] [0.8003] [0.9157]
>> a(:,:)={rand(3,3)}
a =
[3x3 double] [3x3 double] [3x3 double]
[3x3 double] [3x3 double] [3x3 double]
[3x3 double] [3x3 double] [3x3 double]
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询