作业帮 > 综合 > 作业

matlab程序中为什么下面这个式子运行不下去:

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/07/11 23:30:10
matlab程序中为什么下面这个式子运行不下去:
f=zeros(2,1);
f(1)=real(dptotal);
f(2)=imag(dptotal);
其中dptotal为复数
程序提示是 In an assignment A(I) = B,the number of elements in B
and
I must be the same.
matlab程序中为什么下面这个式子运行不下去:
a=randint(1,3,[1 5]);
>> b=randint(1,3,[1 5]);
>> dptotal=complex(a,b)
dptotal =
5.0000 + 5.0000i 5.0000 + 1.0000i 3.0000 + 2.0000i>> f(1)=real(dptotal)
>> f(1)=real(dptotal)
? In an assignment A(I) = B, the number of elements in B and
I must be the same.
%%%可以看出f的尺寸和real(dptotal)的尺寸不一致
>> f(1,:)=real(dptotal)
f =
5 5 3
>> f(2,:)=imag(dptotal)
f =
5 5 3
5 1 2