フィルターのクリア

I am trying to convert a .dat file to 3D contour plot but whenever I am importing the data onto MATLAB, the 3D contour plot option becomes unavailable for my table of data.

2 ビュー (過去 30 日間)
Here, is a small part of my data from the .dat file, kindly suggest me a method to get the 3D contour plot for this data
0.187248036900544 0.225000000000024 0.0101747836706387
0.200615560764072 0.225000000000024 0.0134358996466722
0.200615560764072 0.977319587628889 0.00843502395192389
0.200615560764072 2.02500000000003 6.91121679273313E-4
0.240837272376043 0.225000000000024 0.0108791749604607
0.240837272376043 0.977319587628889 0.00769656121639112
0.240837272376043 2.02500000000003 8.55892337623014E-4
0.240837272376043 3.00000000000002 1.0054815465028E-5
0.277291706360751 0.225000000000024 0.00955485041643158
0.277291706360751 0.977319587628889 0.00670227530123558
0.277291706360751 2.02500000000003 7.64630936219128E-4
0.277291706360751 3.00000000000002 -7.59054650127321E-5
0.277291706360751 3.97613065326636 -2.47208464277737E-5
0.311870304800838 0.225000000000024 0.0094448719156395
0.311870304800838 0.977319587628889 0.00627927491226511
0.311870304800838 2.02500000000003 6.63069929623771E-4
0.311870304800838 3.00000000000002 -2.14615889790147E-5
0.311870304800838 3.97613065326636 -3.13478095562815E-5
0.34691751064302 0.225000000000024 0.00943575363703072
0.34691751064302 0.977319587628889 0.00630187025701187
0.34691751064302 2.02500000000003 6.50546979119222E-4
0.34691751064302 3.00000000000002 -3.68598288449549E-6
0.34691751064302 3.97613065326636 -5.43790937268387E-5
0.34691751064302 5.02500000000004 -2.88773522827011E-4
0.381845842418074 0.225000000000024 0.0092627611972251

回答 (1 件)

Bhanu Prakash
Bhanu Prakash 2023 年 10 月 19 日
Hi Sanskriti,
As per my understanding, you have a .DAT file and want to plot a 3D contour with it.
You can import the data file using the ‘importata’ function in MATLAB. The coordinates (x,y,z) can be obtained with the help of array indexing as shown in the below code.
% Import the data from the .dat file
data = importdata('your_file_name.dat');
% Extract x, y, and z coordinates from the data
x = data(:, 1);
y = data(:, 2);
z = data(:, 3);
To plot a contour, a grid of ‘x’ and ‘y’ values are required, which can be created using the ‘meshgrid’ function. To plot a 3D contour with (x,y,z) coordinates, the size of grid Z’ should be same as that of ‘X’ and ‘Y grids. This can be achieved using the ‘griddata’ function as shown below:
% Create a grid for interpolation
[X, Y] = meshgrid(unique(x), unique(y));
% Interpolate the data to create a grid
Z = griddata(x, y, z, X, Y);
After creating the (X,Y,Z) grids, a 3D contour can be plotted using the ‘contour3’ function by passing the grid values as arguments as shown below.
% Create a 3D contour plot
figure;
contour3(X, Y, Z);
xlabel('X');
ylabel('Y');
zlabel('Z');
title('3D Contour Plot');
For more information on the afore-mentioned functions, refer to the following documentation:
1. For ‘importdata’ function:
2.For ‘meshgrid’ function:
3.For ‘griddata’ function:
4.For ‘contour3’ function:

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by