In a 3d graph. Can we put limits on z axis w.r.t. x and y axis?

2 visualizaciones (últimos 30 días)
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
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
Shubham Mohan Tatpalliwar el 3 de Oct. de 2018
Editada: Shubham Mohan Tatpalliwar el 3 de Oct. de 2018
hello jonas Actually the black line you see are the limits of y axis w.r.to x and z axis and the values are in previous comment i was also thinking of NaN but the input could be canged every time
so i just want to have a matrix which would nullify the the data above these limits
like a matrix of idx which has the value 1 within limits and 0 beyond limits.
i would multiply this expected matrix with my result and ultimately would the the graph everytime within limits

Iniciar sesión para comentar.

Respuesta aceptada

jonas
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
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar el 5 de Oct. de 2018
Hello, Yesterday i was working on it
and i got at first this type of result but i ignored
AND NOW I AM GETTING THE SAME RESULTS FOR THE SAME PROGRAM
Can u tell me whats wrong with it
jonas
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.

Iniciar sesión para comentar.

Más respuestas (0)

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!

Translated by