Creating a mesh in a 3-d plot.

6 ビュー (過去 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 Center および File ExchangeSurface 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