i have text with data an di dont know how to create a surface plot using surf function.
load('exportfilecst4.txt');
X = exportfilecst4(:,1);
Y = exportfilecst4(:,2);
z1 = exportfilecst4(:,4);
z2 = exportfilecst4(:,5);
z3 = exportfilecst4(:,6);
Z = z3;
plot3(X,Y,Z,'*','markerSize',3);
grid on
this is my code right now
i have attach the text file bellow
can anyone change it to surface plot

 채택된 답변

Akira Agata
Akira Agata 2019년 8월 21일

1 개 추천

Like this?
data = dlmread('exportfilecst4.txt');
x = data(:,1);
y = data(:,2);
z = data(:,6);
figure
surf(reshape(x,31,[]),reshape(y,31,[]),reshape(z,31,[]))
surf.png

댓글 수: 7

Stephen23
Stephen23 2019년 8월 21일
son nguyen xuan's incorrectly accepted "Answer" moved here:
oh thank you so much
son nguyen xuan
son nguyen xuan 2019년 8월 21일
i'm sorry can you explain further how would you choose number 31? cause when i apply the code to another file, it can not produce a result
thank you
Akira Agata
Akira Agata 2019년 8월 21일
Hi son nguyen xuan-san,
This is because, looking at your data, x (=> 1st column) value repeats 31 times.
형섭 김
형섭 김 2021년 11월 20일
hi , nice to meet you.
This is Hyoung Sup Kim from Korea.
Can I ask a question about reshape function?
I applied your command for my project.
But, it didn't work.
I will attach my data.txt file.
Please correct your code.
Thanks
From hskim
Hi @형섭 김-san,
Looking at your data file, column-1 and -2 ware not sorted (I'm not sure why the data was saved in this order...).
Anyway, you can do the same thing by sorting the data, like:
% Read data file
D = readmatrix('uniformity_raw_1108_1118_7.56percent.txt',...
'Delimiter','\t\t');
% Sort the data
D = sortrows(D,[1 2]);
% Reshape to make grid-style data array
xGrid = reshape(D(:,1),5,[]);
yGrid = reshape(D(:,2),5,[]);
zGrid = reshape(D(:,3),5,[]);
% Visualize the data
figure
surf(xGrid, yGrid, zGrid)
형섭 김
형섭 김 2021년 12월 5일
Dear Akira
Thank you for your kindly advice.
I have question.
I didn't recognize your feedback until I access matlab site.
How can I check your feedback immediately?
From hskim
Walter Roberson
Walter Roberson 2021년 12월 5일
When you are editing something here on MATLAB Answers, if you look between the edit box and the Cancel / Submit line, then there is a checkbox for "Follow activity on this question" and that is followed on the same line by "(change notification settings)". You can click on "notification settings" to access the Notification Preferences window.
The first preference you can set on that page is for
MATLAB Answers
Activity on questions you have followed in MATLAB Answers
If you select "High" then you will get notification by email as soon as there is any activity on a question you have "Followed". If you select "Medium" then you will get a list once a day by email about questions that there has been activity on. If you select "None" then there will be no email about MATLAB Answers activity.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Downloads에 대해 자세히 알아보기

질문:

2019년 8월 21일

댓글:

2021년 12월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by