How to do the 3D vector plot from dataset?
6 ビュー (過去 30 日間)
古いコメントを表示
I want to plot like (picture) this but I don't know what I did wrong with my code. Using the data set in excel file (in the attachment).
In Excel file, The first 3 columns are the position in x, y, z axes and the last 3 columns are the magnetic field in x, y, z axes as Bx, By and Bz.
Each arrows that shown in the 3D graph are the magnitude of magnetic field :
MagB = sqrt(Bx^2+By^2+Bz^2)
Thank you very.
clear all;
close all;
L1 = xlsread('11x11x11 in 3D.xlsx');
N1=11;
N2=11;
N3=11;
l = 1;
for i = 1 : 1 : N1
for j = 1 : 1: N2
for k = 1 : 1 : N3
l = (i-1)*N2*N3+((j-1)*N3+k);
X(k,j,i) = L1(k, 1);
Y(k,j,i) = L1(k, 2);
Z(k,j,i) = L1(k, 3);
X1(k,j,i) = L1(k, 4);
Y1(k,j,i) = L1(k, 5);
Z1(k,j,i) = L1(k, 6);
end
end
end
quiver3(X,Y,Z,X1,Y1,Z1)

0 件のコメント
回答 (1 件)
Cris LaPierre
2019 年 4 月 9 日
Here's the code that will load and plot the data.
opts = detectImportOptions("11x11x11 in 3D.xlsx");
opts.VariableNames = {'X','Y','Z','Bx','By','Bz'};
data = readtable('11x11x11 in 3D.xlsx',opts);
quiver3(data.X,data.Y,data.Z,data.Bx,data.By,data.Bz)
I don't know what you are trying to do with your code. The plot you get with my code will not look like the image you've shared. You should take a look at your data if you don't understand why.
2 件のコメント
Daynah Rodriguez
2020 年 8 月 4 日
編集済み: Daynah Rodriguez
2020 年 8 月 4 日
Hey Cris,
I used this same code to plot Jupiter's magnetic field (Bx,By,Bz) from Juno's XYZ position. Is this a correct representation of it?

Cris LaPierre
2020 年 8 月 4 日
I can't see anything wrong with your plot, but I do not have enough background in the magnetic fields of Jupiter to be able to tell you if it is correct or not.
参考
カテゴリ
Help Center および File Exchange で Vector Fields についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!