I'm looking for a way to draw the attached data (X,Y,S) as 2D graph with S being the color or as 3D graph that includes (X,Y,S) I have tried the mesh and surf. however, the plot doesn't give much information and the resulted shape is wrong, since the ultimate shape should looks like ( + ). Can anyone please help me with this?

2 Kommentare

Jan
Jan am 28 Okt. 2020
Please make it as easy as possible to answer your question. Post the code you have already, such that the readers do not have to guess, which code is producing, what you think is wrong.
Abdulkarim Almukdad
Abdulkarim Almukdad am 28 Okt. 2020
Bearbeitet: Abdulkarim Almukdad am 29 Okt. 2020
Sorry for that, please see below the code I have used to assign the variables and to plot. From the below code you will see I have used different plot3D functions but all of them are showing the same mistake (left side is connected somehow with the top and bottom parts) please see attached Figure its exactly what I'm looking for (my output should be close to it). I also have one comment which is I guess the boundary function can fix this issue but I don't know how to do it.
NewTable = readtable('Test1.xlsx');
TTT=NewTable{1:1:end, contains(NewTable.Properties.VariableNames, 't')};
XXX=NewTable{1:1:end, contains(NewTable.Properties.VariableNames, 'X')};
YYY=NewTable{1:1:end, contains(NewTable.Properties.VariableNames, 'Y')};
SSS=NewTable{1:1:end, contains(NewTable.Properties.VariableNames, 'S')};
figure
surface(XXX,YYY,SSS);
figure
surfc(XXX,YYY,SSS);
figure
mesh(XXX,YYY,SSS)
figure
contour(XXX,YYY,SSS)
figure
pcolor(XXX,YYY,SSS)
colorbar
shading interp

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

KSSV
KSSV am 28 Okt. 2020

0 Stimmen

Try this:
num = xlsread("Test1.xlsx") ;
[r,c] = size(num');
n = r/9;
% Arrange the data
A = permute(reshape(num,[c,r/n,n]),[2,1,3]);
A = permute(A,[2 1 3]) ;
% get x,y,s
x = squeeze(A(:,2,:)) ;
y = squeeze(A(:,3,:)) ;
s = squeeze(A(:,6,:)) ;
% do inteprolation and convert to grid
m = 100 ; n = 100 ;
xi = linspace(min(x(:)),max(x(:)),m) ;
yi = linspace(min(y(:)),max(y(:)),n) ;
[X,Y] = meshgrid(xi,yi) ;
S = griddata(x,y,s,X,Y) ;
% Make exact plus sign
idx = boundary(x(:),y(:)) ;
bx = x(idx) ; by = y(idx) ;
idx = inpolygon(X,Y,bx,by) ;
S(~idx) = NaN ;
% plot
pcolor(X,Y,S)
shading interp
colorbar

4 Kommentare

Abdulkarim Almukdad
Abdulkarim Almukdad am 28 Okt. 2020
Thanks a lot! I have tried many times to follow what you have done but I always ended up with an error. I just have 1 simple question, after I have removed the outliers, as you can see from the below figure as the left side and bottom side there are small yellow dots unlike the right side and above side. Therefore, is there anyway to make the graph more smother ? like to make it ignore the high S value when its only 1 value but to keep the color when more than 2 values next to each other are high. my ultimate goal to make the graph understandable and descriptive. Thanks in advance!
KSSV
KSSV am 29 Okt. 2020
There are few outliers. You can remove the values which are greater than 300.
I have tried many times to follow what you have done but I always ended up with an error.
What error you are getting? Show the error, it can be sorted.
Abdulkarim Almukdad
Abdulkarim Almukdad am 29 Okt. 2020
I meant before you post your code I was trying to do the same but I couldn't so thanks a lot for your help. actually I have removed the outliers above 500 and the graph now is very close to what I want. the only issue is to eliminate those yello dots in the bottom and left side, better without deleting those data and by editing the graph somehow is possible
KSSV
KSSV am 29 Okt. 2020
Read about caxis. You can limit the color values here.....but it will effect the complete plot.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

SNEHAL
SNEHAL am 19 Dez. 2024

0 Stimmen

num = xlsread("Test1.xlsx") ;
[r,c] = size(num');
n = r/9;
% Arrange the data
A = permute(reshape(num,[c,r/n,n]),[2,1,3]);
A = permute(A,[2 1 3]) ;
% get x,y,s
x = squeeze(A(:,2,:)) ;
y = squeeze(A(:,3,:)) ;
s = squeeze(A(:,6,:)) ;
% do inteprolation and convert to grid
m = 100 ; n = 100 ;
xi = linspace(min(x(:)),max(x(:)),m) ;
yi = linspace(min(y(:)),max(y(:)),n) ;
[X,Y] = meshgrid(xi,yi) ;
S = griddata(x,y,s,X,Y) ;
% Make exact plus sign
idx = boundary(x(:),y(:)) ;
bx = x(idx) ; by = y(idx) ;
idx = inpolygon(X,Y,bx,by) ;
S(~idx) = NaN ;
% plot
pcolor(X,Y,S)
shading interp
colorbar

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by