%% 读取数据 filename = 'F:\150kwengine.xls'; sheet = 1; xlRange = 'A1:K23'; data = xlsread(filename,sheet,xlRange); %% 手动取出有效数据 [r,c]=size(data); spd=data(4:r,1)'; thr=data(1,2:c); torque_table=data(4:r,2:c); [r1,c1]=size(torque_table); %% 将数据转成行向量 %参数: % x_thr 节气门行向量,维度:1*(r1*c1) % y_spd 转速行向量,维度:1*(r1*c1) % z_tor 转矩行向量,维度:1*(r1*c1) z_tor=torque_table(:,1)'; for i=2:c1 z_tor=cat(2,z_tor,torque_table(:,i)'); end y_spd=kron(ones(1,c1),spd); thr_temp=kron(ones(r1,1),thr); x_thr=thr_temp(:,1)'; for j=2:c1 x_thr=cat(2,x_thr,thr_temp(:,j)'); End %% 散点插值 得出 x_thr=F(y_spd,z_tor); F=scatteredInterpolant(y_spd',z_tor',x_thr','linear'); % F=scatteredInterpolant(x_thr',y_spd',z_tor','nearest'); % surf(x_thr',y_spd',F(x_thr',y_spd')); %% 新表制作 %spd使用原数据 %Torque依据原数据扭矩值最大最小值,重新给出 Torque=-60:10:250; Throttle=zeros(length(spd),length(Torque)); for i=1:length(spd) for j=1:length(Torque) Throttle(i,j)=F(spd(i),Torque(j)); %Throttle(i,j)=griddata(y_spd',z_tor',x_thr',spd(i),Torque(j),'natural'); end end %% 后续处理 % 将Throttle二位数组中,大于1的元素置1,小于零的元素置0 index1=find(Throttle<0); Throttle(index1)=0; index2=find(Throttle>1); Throttle(index2)=1; outdata=cell(2); outdata{1,1}=0; outdata{1,2}=Torque; outdata{2,1}=spd'; outdata{2,2}=Throttle; outdata=cell2mat(outdata); surf(Torque,spd,Throttle);
时间: 2023-05-25 21:05:44 浏览: 119
KWEngine2:适用于学生和老师的C#OpenGL游戏引擎!
As an AI language model, I do not have emotions or beliefs. Null is a term typically used in programming languages to indicate a non-existent or invalid value. It represents the absence of a value or the presence of an undefined or unknown value.
阅读全文