function [Kraftstoffverbrauch,Wi, Drehzahl, 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,Drehmoment,Kraftstoffverbrauch)
xlabel ('Drehzahl(1/min)');ylabel ('Drehmoment(N.m)'); zlabel ('Kraftstoffverbrauch(kWh/100km)');
title ('Drehmoment vs Drehzahl Diagram');
end

댓글 수: 8

JohnGalt
JohnGalt 2018년 10월 1일
use the '{}code' button to make your code more readable please...
JohnGalt
JohnGalt 2018년 10월 1일
also what are the inputs 'Drehzahl, Drehmoment'
t = linspace(3/4*pi,2*pi,50)';
Drehzahl = [3*cos(t); 2*cos(t); 0.7*cos(t)];
Drehmoment = [3*sin(t); 2*sin(t); 0.7*sin(t)];
[Kraftstoffverbrauch,Wi]=Kasus_1_4(Drehzahl, Drehmoment)
on another note, it's better practice to add the filename as input to the function e.g.
function [Kraftstoffverbrauch,Wi, Drehzahl, Drehmoment]=Kasus_1_4(mappeXLSXname,Drehzahl, Drehmoment)
...
[num,txt,raw] = xlsread(mappeXLSXname) ;
...
Also, it's unusual to have the same arguments in the input and the output... as whatever's calling the function already knows the input... and if the input is changing then the output name should be different.
and finally, 'Drehmoment2' is created but not used...
if true
% code
function [Kraftstoffverbrauch,Wi, Drehzahl, Drehmoment]=Kasus_1_4(Drehzahl, Drehmoment)
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,Drehmoment,Kraftstoffverbrauch) xlabel ('Drehzahl(1/min)');ylabel ('Drehmoment(N.m)'); zlabel ('Kraftstoffverbrauch(kWh/100km)');
title ('Drehmoment vs Drehzahl Diagram');
end
end
Drehzahl =500:6000 Drehmoment=5:250
i have nullified minuteerrors but still the main problem is not solved which is expected from my question
Your expected is pretty much a contour() plot except with the value at each point text() into place. Your code makes no attempt to contour or text labels into place.
JohnGalt
JohnGalt 2018년 10월 1일
aside from the labelling... the issue is that your inputs scale linearly with each other ... so of course you're going to get a straight line...
what changes should i make to get the expected one

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2018년 10월 1일

0 개 추천

Should try something like this:
[num,txt,raw] = xlsread('Mappe1.xlsx') ;
% [num,txt,raw] = xlsread('Mappe1.xlsx') ;
x = num(:,1) ; x(isnan(x))= [ ];
A = num(:,2:end) ;
A(isnan(A(:,1)),:)= [] ;
Y = A(1:2:end,:) ;
Z = A(2:2:end,:) ;
X = repmat(x,1,size(Y,1)) ;
contour(X,Y,Z','ShowText','on')

댓글 수: 3

Hey thanx... i got the concept but the problrm is that i want the graph for kraftstoffverbrauch. which is a matrix
and for that the Wi(Z) values are in vector. which not expected as a result
KSSV
KSSV 2018년 10월 1일
You frame your vectors and arrange them into a matrix.
Actually i am trying to get Z in matrix form form but failed

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by