Plot 4d data

5 ビュー (過去 30 日間)
Matthew Worker
Matthew Worker 2019 年 10 月 1 日
編集済み: N/A 2021 年 6 月 18 日
hi :) how can one import an excel sheet with x, y, z and V columns as a 3d matrix? I am trying to plot the V values over a co ordiante system (using slice function) .
Thanks!

回答 (1 件)

Joe Vinciguerra
Joe Vinciguerra 2019 年 10 月 1 日
May not be the most efficient, but this is what I came up with:
Here's my sample data based on my interpretation of your description:
Capture.JPG
% Load the data from the source file
[filename, pathname] = uigetfile('*.xls*','MultiSelect','off'); % open file selection dialog
ScriptFolder = cd(pathname); % change to the folder location you selected so you can read the file
A = readmatrix(filename); % read the file you selected
% assign to seperate variables for clarity
x = A(:,1);
y = A(:,2);
z = A(:,3);
% build a multidimensional array (again, may not be the most efficient approach)
% https://www.mathworks.com/help/matlab/math/multidimensional-arrays.html
for i=1:length(A)
V(x(i),y(i),z(i)) = A(i,4);
end
% plot using the slice function
% https://www.mathworks.com/help/matlab/ref/slice.html
xslice = [1,2,3];
yslice = [];
zslice = [2];
slice(V,xslice,yslice,zslice)
untitled.jpg

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by