有关matlab——我想把符合条件的数值存入矩阵中,不过这组数的长度是变 ...答:>> a = [0.2,0.5,0.7,0.8,1.1,1.2,1.4,1.6,1.8,1.9,2.0];tj1 = a>0 & a<=1; % 条件1 tj2 = a>1 & a<=2; % 条件2 am1 = mean(a(tj1))am2 = mean(a(tj2))am1 = 0.5500 am2 = 1.5714 ...
使用matlab读取txt文件,并将其中的数字数据写入矩阵中答:clear;clc[a,b]=uigetfile('*.*','Please Select The File');if(a) f=fopen(strcat(b,a),'r'); s=fread(f,'*char').'; fclose(f); A=cell2mat(cellfun(@str2num,regexp(s,'(?<=A\d+\s+)\d+\s+\d+\s+\d+(?=\s+)','match'),'UniformOutput',0).')...