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

조회 수: 2 (최근 30일)
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar 2018년 10월 2일
편집: jonas 2018년 10월 5일
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
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.
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar 2018년 10월 3일
편집: Shubham Mohan Tatpalliwar 2018년 10월 3일
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

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

채택된 답변

jonas
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
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar 2018년 10월 5일
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 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 CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by