MAtlab中To RESHAPE the number of elements must not change.N1=14328;N2=14328;fid=fopen('ddfield.E15','r');size=fscanf(fid,'%g');fclose(fid);aa1=reshape(size,9,N1*N2);% X=reshape(aa1(1,:),N1,N2);% Y=reshape(aa1(2,:),N1,N2);% Z=reshape(aa1(3,:),N1,N2);X=linspace(-15,15,N1);Y=linspace(-15,15,N2);Ex=reshape(aa1(4,:),N1,N2)+i*reshape(aa1(5,:),N1,N2);Ey=reshape(aa1(6,:),N1,N2)+i*reshape(aa1(7,:),N1,N2);Ez=reshape(aa1(8,:),N1,N2)+i*reshape(aa1(9,:),N1,N2);E=(a
问题描述:
MAtlab中To RESHAPE the number of elements must not change.
N1=14328;
N2=14328;
fid=fopen('ddfield.E15','r');
size=fscanf(fid,'%g');
fclose(fid);
aa1=reshape(size,9,N1*N2);
% X=reshape(aa1(1,:),N1,N2);
% Y=reshape(aa1(2,:),N1,N2);
% Z=reshape(aa1(3,:),N1,N2);
X=linspace(-15,15,N1);
Y=linspace(-15,15,N2);
Ex=reshape(aa1(4,:),N1,N2)+i*reshape(aa1(5,:),N1,N2);
Ey=reshape(aa1(6,:),N1,N2)+i*reshape(aa1(7,:),N1,N2);
Ez=reshape(aa1(8,:),N1,N2)+i*reshape(aa1(9,:),N1,N2);
E=(abs(Ex).^2+abs(Ey).^2+abs(Ez).^2).^(1/2);
figure,imagesc(X,Y,E)
colorbar
答
你要reshape的话变之前和变了之后元素总数得相等, 你不可能把一个1000个元素的矩阵reshape成含有2000元素的矩阵