Represent the figures on the XZ (or YZ) plane
Show older comments
Hi! I would like to modify my code so that the figures are shown on the XZ (or YZ) plane and not on the XY plane (as in my code).
How can I modify it?
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
myFolder = 'C:\Users\...';
filePattern = fullfile(myFolder, '*.png');
imageFiles = dir(filePattern);
hFig3 = figure('Name', '3D Plot', 'NumberTitle', 'off');
% z-coordinates to use:
z = 1+100*(0:numel(imageFiles)-1); %[1 101 201 ...]
for k = 1:length(imageFiles)
baseFileName = imageFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
drawnow;
% Call pic2points. This will open a new figure.
CoordinateMatrix = pic2points(imageArray);
% Switch to the figure for the 3-D plotting:
figure(hFig3);
% scatter(CoordinateMatrix(:, 1), CoordinateMatrix(:, 2), '.');
current_z = z(k) * ones(size(CoordinateMatrix, 1), 1);
plot3(CoordinateMatrix(:, 1), CoordinateMatrix(:, 2), current_z, '.');
hold on
drawnow;
end
grid on;
hFig3.WindowState = 'maximized';
fprintf('Done running %s.m.\n', mfilename);
xlabel('axis X')
ylabel('axis Y')
zlabel('axis Z')
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown 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!