Question
The following is my skeleton MATLAB code from moving a solidworks ASCII part file over a line. However, my question is how do I import
The following is my skeleton MATLAB code from moving a solidworks ASCII part file over a line. However, my question is how do I import my file into the MATLAB code? Specifically, the NewD and addpath lines in the beginning of the skeleton code. I understand that it will be specific to where I saved the document, but would somone be able to show me an example so I can comprehend how to achieve this?
clear all clc
% Add working directories to current path newD = fullfile(pwd,'../'); addpath(genpath(newD));
% File names of the CAD geometry to convert to polygons FileName = {'cylinder.STL'};
% Converts CAD geometry into multiple polygons and into its vertices % The vertices all ready include the bottom row of ones, % that is V = [Pnts;1] [P,V] = cad2polyRev(FileName);
% using scaling matrix % Sx = 0.5; sy = 0.5; sz = 0.5; %V{1} = [sx 0 0 0 ;0 sy 0 0;0 0 sz 0;0 0 0 1]*V{1};
% Color options yellow,magenta,cyan,red,green,blue,white, black set(P(1),'FaceColor','magenta') % set color of filename geometry
fprintf(' Animation is ready!! Please hit return to continue. ') pause
% Set axis manually axis([-1 6 -.25 1]); hold on;
%View in 2-D view(2); %
h0 = []; % Animated robot title('Rolling Wheel') r = 0.5; %radius of the wheel dx = 0.05; % change in x coordinate cw = -1; % clockwise
% Allocate memory for vectors npts = 100; x = inf(1,npts); y =inf(1,npts); theta = inf(1,npts);
for k = 1:npts, % Center of the whe x(k) = (k-1)*dx; y(k) = r; theta(k) = cw*(x(k)/r)*180/pi;% Rotate wheel clockwise drawWheel(P,V,theta(k),x(k),y(k)) %draws road path h = plot(x(1:k),y(1:k)-r,'-'); % Deletes previous line used to draw road path set(h0, 'XData', [], 'YData', []) drawnow() h0 = h; % pause program for .05 sec to see animation pause(.05) end % End AnimateWheel.m
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started