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!