フィルターのクリア

Plot a function of three variables on a surface plot

25 ビュー (過去 30 日間)
Fawad Farooq Ashraf
Fawad Farooq Ashraf 2023 年 3 月 30 日
編集済み: Torsten 2023 年 4 月 2 日
Hello. I have some experimental data of electric field E. The values were measured along three axes x, y and z such that: along x axis (x=0:5:50), values of Ex were measured (Assume Ex = rand(size(x)) for reference), then along y axis (y=0:5:70), values of Ey were measured (Assume Ey = rand(size(y)) here for reference), and along z axis (0:5:20), Ez was measured (Ez = rand(size(z)) assumed here). I want to plot this data in a 3D surface plot. How can I do this?
  1 件のコメント
Torsten
Torsten 2023 年 4 月 2 日
編集済み: Torsten 2023 年 4 月 2 日
So given a point (x,y,z) in 3d space, what do you want to plot at this point ? sqrt(Ex^2+Ey^2+Ez^2) ?

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2023 年 3 月 30 日
If all the data are vectors (that would appear to be true since ‘x’ is a vector), it would be necessary to use either the griddata or scatteredInterpolant function to create a surface from them.
.
  2 件のコメント
Fawad Farooq Ashraf
Fawad Farooq Ashraf 2023 年 4 月 2 日
how to do that? I don't understand these functions.
Star Strider
Star Strider 2023 年 4 月 2 日
Here is an example using scatteredInterpolant and random vectors —
x = randn(1,20); % Create Data Vector
y = randn(1,20); % Create Data Vector
z = randn(1,20); % Create Data Vector
xv = linspace(min(x), max(x), numel(x)); % Interpolatioon Vector
yv = linspace(min(y), max(y), numel(y)); % Interpolation Vector
[X,Y] = ndgrid(xv,yv); % Interpolation Matrices
F = scatteredInterpolant(x(:),y(:),z(:)); % Create Interpolant Function
Z = F(X,Y); % Calculate 'Z' By Interpolation
figure
surfc(X, Y, Z) % Plot Result
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
colormap(turbo) % Introduced In R2020b
colorbar
The griddata function works similarly, however has different arguments and produces a lsightly different result.
.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by