Creating a mesh in a 3-d plot.

조회 수: 5 (최근 30일)
ragnor
ragnor 2021년 8월 17일
댓글: ragnor 2021년 8월 17일
Hello matlab community,
Can someone please help me to create a mesh surface where the points are connected and it looks like the picture attached. I have the following code which just connects the points with the line but the surface is not seen. I am not able to figure the meshgrid and how to apply it to fit my requirement. I would be really grateful if somone can help.
opts = detectImportOptions('Data1.xlsx');
opts1 = detectImportOptions('Data2.xlsx');
% Load data
data = readtable('Data1.xlsx', opts);
data1 = readtable('Data2.xlsx', opts1);
x1 = data{:,1};
y1 = data{:,2};
z1 = data{:,3};
x2 = data1{:,1};
y2 = data1{:,2};
z2 = data1{:,3};
figure(1)
plot3(y1,x1,z1, 'x-o','LineWidth',1);
hold on;
plot3(y2,x2,z2, 'x-o','LineWidth',1);
hold off;
legend('$25^{\circ}C$','$150^{\circ}C$',...
'Location','northoutside','Orientation','horizontal')

채택된 답변

Yazan
Yazan 2021년 8월 17일
편집: Yazan 2021년 8월 17일
clc, clear, close all
opts = detectImportOptions('Data1.xlsx');
opts1 = detectImportOptions('Data2.xlsx');
% Load data
data = readtable('Data1.xlsx', opts);
data1 = readtable('Data2.xlsx', opts1);
x1 = data{:,1};
y1 = data{:,2};
z1 = data{:,3};
x2 = data1{:,1};
y2 = data1{:,2};
z2 = data1{:,3};
xx1 = reshape(x1(:), [], length(unique(x1)));
yy1 = reshape(y1(:), length(unique(y1)), []);
zz1 = reshape(z1(:), size(xx1));
surf(yy1, xx1, zz1, 'FaceColor', 'b', 'FaceAlpha', 0.1, 'EdgeColor', 'b', 'Marker', ...
's', 'MarkerSize', 7, 'MarkerFaceColor', 'b');
hold on
xx2 = reshape(x2(:), [], length(unique(x2)));
yy2 = reshape(y2(:), length(unique(y2)), []);
zz2 = reshape(z2(:), size(xx2));
surf(yy2, xx2, zz2, 'FaceColor', 'r', 'FaceAlpha', 0.1, 'EdgeColor', 'r', 'Marker',...
's', 'MarkerSize', 7, 'MarkerFaceColor', 'r');
xlabel('I_{on} [A]'), ylabel('V_{block} [V]'), zlabel('E [mJ]')
legend(' 25^o', ' 150^o')
  댓글 수: 1
ragnor
ragnor 2021년 8월 17일
@Yazan: Thank you so much, i have no words to express my gratitude :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by