In a 3d graph. Can we put limits on z axis w.r.t. x and y axis?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Shubham Mohan Tatpalliwar
el 2 de Oct. de 2018
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 comentarios
jonas
el 2 de Oct. de 2018
Editada: jonas
el 2 de Oct. de 2018
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.
Shubham Mohan Tatpalliwar
el 3 de Oct. de 2018
Editada: Shubham Mohan Tatpalliwar
el 3 de Oct. de 2018
Respuesta aceptada
jonas
el 3 de Oct. de 2018
Editada: jonas
el 5 de Oct. de 2018
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 comentarios
jonas
el 5 de Oct. de 2018
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!