clc;clear;close B=zeros(100,100)*1/0; row=10; num=[]; for i=1:row A=[]; A = 1:2:2*i; num=[num length(A)]; B(i,1:length(A))=A; end column=max(num); C=B(1:row,1:column) save(\'test_C.txt\',\'C\',\'-ascii\') a=1:10; b=1:20; num=[]; num=[num length(a)]; num=[num length(b)]; %依次类推 m=length(num); n=max(num); c=zeros(m,n)*1/0; %用无穷bai大填充NaN %c=zeros(m,n); %用零填du充 c(1,1:num(1))=a; c(2,1:num(2))=b; c %p(3,~isnan(p(3,:))) %读取质数
上面为保存不同长度的数列到矩阵中,并保存到TXT文件当中