In a 3d graph. Can we put limits on z axis w.r.t. x and y axis?
2 ビュー (過去 30 日間)
古いコメントを表示
if true
% code
function [Kraftstoffverbrauch, Drehzahl, Drehmoment]=Kasus2_1(Drehzahl, Drehmoment)
% Modify the dimensions
nx = length(Drehzahl) ;
ny = length(Drehmoment) ;
if nx > ny
Drehmoment1 = linspace(min(Drehmoment),max(Drehmoment),nx ) ;
elseif nx<ny
Drehzahl1 = linspace(min(Drehzahl),max(Drehzahl),ny) ;
end
[num,txt,raw] = xlsread('Mappe2.xlsx') ;
Dz = num(:,1) ; Dz(isnan(Dz))= [ ];
Dm = num(:,2) ;Dm(isnan(Dm))= [ ];
Kv = num(:,3) ;Kv(isnan(Kv))= [ ];
F = scatteredInterpolant([Dz Dm],Kv);
for i= 1:1:nx
for j= 1:1:ny
Kraftstoffverbrauch (i,j) = F(Drehzahl(i),Drehmoment(j));
end
end
surf(Drehzahl,Drehmoment,Kraftstoffverbrauch'),xlabel ('Drehzahl(1/min)');ylabel ('Drehmoment(N.m)'); zlabel ('Kraftstoffverbrauch(kWh/100km)');
title ('Drehmoment vs Drehzahl Diagram');
end
The display of he expected limits can be sssn in the picture
5 件のコメント
jonas
2018 年 10 月 2 日
編集済み: jonas
2018 年 10 月 2 日
It is still unclear what you mean. What did you sketch? The thick black line? Do you want to have a non-rectangular grid? If so, then you can just place NaN's where you do not want data. Please upload some data and perhaps a more detailed explanation if you need more help.
採用された回答
jonas
2018 年 10 月 3 日
編集済み: jonas
2018 年 10 月 5 日
I made your code a bit faster and fixed your problem.
%%Load data
[num,txt,raw] = xlsread('Mappe2.xlsx') ;
x = num(:,1);
y = num(:,2);
z = num(:,3);
x(isnan(x)) = [];
y(isnan(y)) = [];
z(isnan(z)) = [];
%%Interpolate
F = scatteredInterpolant([x y],z);
[X,Y] = meshgrid(1000:5500,0:250);
Z = F(X,Y);
%%Define region where you want to keep data
xp = 1000:250:5500;
yp =[160,180,200,220,220,218,216,215,219,220,220,220,220,220,220,210,200,195,175];
ax = gca;
xp = [xp max(xp) min(xp) min(xp)];
yp = [yp min(Y(:)) min(Y(:)) yp(1)];
%%Find points inside of this region and remove others
in = inpolygon(X(:),Y(:),xp,yp);
Z(~in) = NaN;
%%Plot
figure;hold on
surf(X,Y,Z,'edgecolor','none')
4 件のコメント
jonas
2018 年 10 月 5 日
Something wrong with the polygon, the lower right corner has not been defined correctly. Make sure to clear variables between runs. Also, it was probably not so wise of me to use axes limits in the definition of the polygon edges. I will update with a more robust approach in a bit.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!