Plot 4d data
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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:
% 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
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!