Creating a mesh in a 3-d plot.
조회 수: 5 (최근 30일)
이전 댓글 표시
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')
댓글 수: 0
채택된 답변
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')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!