How to put unequal range of values in functon

1 vue (au cours des 30 derniers jours)
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar le 25 Sep 2018
Réponse apportée : KSSV le 25 Sep 2018
i have made a function for getting interpolated values and in this function i want to give input of unequal range of drehzahl and drehmoment. i have attached the file of the program and its excel sheet
  6 commentaires
KSSV
KSSV le 25 Sep 2018
Copy here a full working code with given inputs..then we can work on the issue of unequal case.
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar le 25 Sep 2018
Modifié(e) : KSSV le 25 Sep 2018
function [Kraftstoffverbrauch,Drehmoment]=Kasus_1_4(Drehzahl, Drehmoment)
[num,txt,raw] = xlsread('Mappe1.xlsx') ;
Dz = num(:,1) ; Dz(isnan(Dz))= [ ];
A = num(:,2:end) ;
A(isnan(A(:,1)),:)= [] ;
W = A(1:2:end,:) ;
Dm = A(2:2:end,:) ;
Dz1 = repmat(Dz,1,size(Dm,1)) ;
idx = ~isnan(Dm) ;
F = scatteredInterpolant([Dz1(idx) Dm(idx)],W(idx));
Wi = F(Drehzahl,Drehmoment);
Drehmoment2 = Drehmoment*3.0769*2.64;
Geschwindigkeit= (Drehzahl/(3.07*2.64))*2.037*0.06;
Kraftstoffverbrauch= (2*3.14*(Drehmoment).*(Drehzahl))./(Wi*0.98*0.8.*(Geschwindigkeit)*600);
plot3(Drehzahl,Drehmoment2,Kraftstoffverbrauch)
end
Drehzahl=1:3000
Drehmoment=100:150
the input range would be variable every time

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 25 Sep 2018
function [Kraftstoffverbrauch,Drehmoment]=Kasus_1_4(Drehzahl, Drehmoment)
% Modify the dimensions
nx = length(Drehzahl) ;
ny = length(Drehmoment) ;
if nx > ny
Drehmoment = linspace(min(Drehmoment),max(Drehmoment),nx) ;
elseif nx<ny
Drehzahl = linspace(min(Drehzahl),max(Drehzahl),ny) ;
end
[num,txt,raw] = xlsread('Mappe1.xlsx') ;
Dz = num(:,1) ; Dz(isnan(Dz))= [ ];
A = num(:,2:end) ;
A(isnan(A(:,1)),:)= [] ;
W = A(1:2:end,:) ;
Dm = A(2:2:end,:) ;
Dz1 = repmat(Dz,1,size(Dm,1)) ;
idx = ~isnan(Dm) ;
F = scatteredInterpolant([Dz1(idx) Dm(idx)],W(idx));
Wi = F(Drehzahl,Drehmoment);
Drehmoment2 = Drehmoment*3.0769*2.64;
Geschwindigkeit= (Drehzahl/(3.07*2.64))*2.037*0.06;
Kraftstoffverbrauch= (2*3.14*(Drehmoment).*(Drehzahl))./(Wi*0.98*0.8.*(Geschwindigkeit)*600);
plot3(Drehzahl,Drehmoment2,Kraftstoffverbrauch)
end

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by