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.
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程序中为什么下面这个式子运行不下去:](/uploads/image/z/10577973-21-3.jpg?t=matlab%E7%A8%8B%E5%BA%8F%E4%B8%AD%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8B%E9%9D%A2%E8%BF%99%E4%B8%AA%E5%BC%8F%E5%AD%90%E8%BF%90%E8%A1%8C%E4%B8%8D%E4%B8%8B%E5%8E%BB%EF%BC%9A)
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
>> 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