Contour Plot Wrong Colors
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi guys,
I have made a contourf interpolating results with meshgrid and it plots a graph which does not correspond to the values that I put as input with the colors of the colorbar (There are points where it should be yellow or red and it is blue, or other points which have markedly different values and are the same color). I don't know if it's a problem with the interpolation method, I think not since I've checked that and the numbers are consistent. I don't see a problem with the contour either. I don't know if I should use another interpolation method and I dont unterstand what exactly is wrong.
clear all;clc;
A=[77.3139227401096,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.8499350764564,77.8442382759329,77.8400158037560,77.8367460305253,77.8341382601430,77.3189088790396,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.4228460196533,77.3770975908979,77.3678714954335,77.3624256179988,77.3588314539844,77.3562741687948,77.3543880471537,77.3529118848689,77.3517359358068,77.8230143346564,77.5947167588728,77.4572289300964,77.3536200322737,77.2815354478640,77.1958950775090,77.1462000726089,77.1176650859710,77.1045877194747,77.0939198939992,77.0960045406636,77.0936701640036,77.0918470331206,77.0903910018129,78.9250781251261,78.2607772080247,77.8571819100295,77.5445345646900,77.1777675777582,77.1067936547286,77.0560757369439,77.0204796252278,77.0021470133600,76.9934357792392,76.9874018876342,76.9841903129164,76.9834146935698,76.9832804850934];
torque=[-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100];
rpmrange=[6,6,6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,8,8,8,8,8,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5];
[xmesh,ymesh]=meshgrid(torque,rpmrange);
vq=griddata(torque,rpmrange,A,xmesh,ymesh);
contourf(xmesh,ymesh,vq,1000,'EdgeColor','none')
xlabel('Torque increase [%]');
ylabel('RPM range [*10^3]');
title('Torque Sensivity Study');
hc = colorbar;
set(get(hc,'title'),'string','LapTime [s]')
colormap(flipud(jet))
0 comentarios
Respuestas (1)
Star Strider
el 14 de Ag. de 2022
Editada: Star Strider
el 14 de Ag. de 2022
I get a slightly different result when I use ‘torquev’ and ‘rpmrangev’ to define the interpolation grids, so that may be the problem, since ‘torque’ and ‘rpmrange’ are themselves actually (14x4) matrices. My change uses their ranges to define the interpolation matrices.
I also ploted the result based on the original reshaped matrices in the second figure.
Try this —
A=[77.3139227401096,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.8499350764564,77.8442382759329,77.8400158037560,77.8367460305253,77.8341382601430,77.3189088790396,77.3120257063849,77.3120257063849,77.3120257063849,77.3120257063849,77.4228460196533,77.3770975908979,77.3678714954335,77.3624256179988,77.3588314539844,77.3562741687948,77.3543880471537,77.3529118848689,77.3517359358068,77.8230143346564,77.5947167588728,77.4572289300964,77.3536200322737,77.2815354478640,77.1958950775090,77.1462000726089,77.1176650859710,77.1045877194747,77.0939198939992,77.0960045406636,77.0936701640036,77.0918470331206,77.0903910018129,78.9250781251261,78.2607772080247,77.8571819100295,77.5445345646900,77.1777675777582,77.1067936547286,77.0560757369439,77.0204796252278,77.0021470133600,76.9934357792392,76.9874018876342,76.9841903129164,76.9834146935698,76.9832804850934];
torque=[-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100,-40,-30,-20,-10,10,20,30,40,50,60,70,80,90,100];
rpmrange=[6,6,6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,8,8,8,8,8,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.5];
torquev = linspace(min(torque), max(torque), numel(torque));
rpmrangev = linspace(min(rpmrange), max(rpmrange), numel(rpmrange));
[xmesh,ymesh]=meshgrid(torquev,rpmrangev);
vq=griddata(torque,rpmrange,A,xmesh,ymesh);
figure
contourf(xmesh,ymesh,vq,1000,'EdgeColor','none')
xlabel('Torque increase [%]');
ylabel('RPM range [*10^3]');
title('Torque Sensivity Study');
hc = colorbar;
set(get(hc,'title'),'string','LapTime [s]')
colormap(flipud(jet))
torque_mtx = reshape(torque,14,[])
rpmrange_mtx = reshape(rpmrange,14,[])
A_mtx = reshape(A,14,{})
figure
contourf(torque_mtx,rpmrange_mtx,A_mtx,1000,'EdgeColor','none')
xlabel('Torque increase [%]');
ylabel('RPM range [*10^3]');
title('Torque Sensivity Study (Original Matrices)');
hc = colorbar;
set(get(hc,'title'),'string','LapTime [s]')
colormap(flipud(jet))
EDIT — (14 Aug 2022 at 13:14)
figure
surfc(torque_mtx,rpmrange_mtx,A_mtx)
% shading('interp')
% hold on
% contour3(torque_mtx,rpmrange_mtx,A_mtx,50,'-k')
% hold off
xlabel('Torque increase [%]');
ylabel('RPM range [*10^3]');
title('Torque Sensivity Study (Original Matrices)');
hc = colorbar;
set(get(hc,'title'),'string','LapTime [s]')
colormap(flipud(jet))
grid on
view(35,20)
.
0 comentarios
Ver también
Categorías
Más información sobre Contour Plots 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!