Plot 4d data
4 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Joe Vinciguerra
on 1 Oct 2019
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:
% 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)
0 Comments
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!