Question: I have designed a project for projectile motiom problems in MatLab. I need it to be written in Python which I have never used. PLEASE

I have designed a project for projectile motiom problems in MatLab. I need it to be written in Python which I have never used. PLEASE HELP!

MATLAB to PYTHON

function varargout = ProjectileMotion(varargin) % PROJECTILEMOTION MATLAB code for ProjectileMotion.fig % PROJECTILEMOTION, by itself, creates a new PROJECTILEMOTION or raises the existing % singleton*. % % H = PROJECTILEMOTION returns the handle to a new PROJECTILEMOTION or the handle to % the existing singleton*. % % PROJECTILEMOTION('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in PROJECTILEMOTION.M with the given input arguments. % % PROJECTILEMOTION('Property','Value',...) creates a new PROJECTILEMOTION or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ProjectileMotion_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ProjectileMotion_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help ProjectileMotion

% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ProjectileMotion_OpeningFcn, ... 'gui_OutputFcn', @ProjectileMotion_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end

if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT

% --- Executes just before ProjectileMotion is made visible. function ProjectileMotion_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ProjectileMotion (see VARARGIN)

% Choose default command line output for ProjectileMotion handles.output = hObject;

% Update handles structure guidata(hObject, handles);

% UIWAIT makes ProjectileMotion wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = ProjectileMotion_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

%set(handles.edit5,'String', a3);

y0 =str2double(get(handles.edit1,'String')); x0 = str2double(get(handles.edit5,'String')); v0 = str2double(get(handles.edit2,'String')); theta = str2double(get(handles.edit3,'String'));

%convert from degrees to radians. beta = theta*pi/180;

% componets of the init velocity Vy = sin(beta)*v0; Vx = cos(beta)*v0;

% maximun height equation maxh = v0^2*sin(beta)^2/(2*9.81) tmaxh = Vy/9.81; xatmaxh = tmaxh * Vx

% equation for total time t = ((Vy+sqrt(((Vy)^2)+(2*9.8*y0)))/9.8)

% Range is then equal horizantla velocity and the time in the air which we % solved range = t * Vx +x0;

for s = 0:t/100:t y = Vy.*s-4.9.*((s).^2)+y0; x = Vx.*s +x0; h = plot(x,y,'.'); title ('Projectile motion Plot'); xlabel ('Distance(meters)'); ylabel ('Hieght(meters)'); set(h,'MarkerSize', 16); set(h,'color', [1 0 1]); pause(0.0001) hold all; axis tight; end (set(handles.text13,'String',range)); (set(handles.text14,'String',maxh)); (set(handles.text12,'String',t));

axes(handles.axes1)

function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double

% --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

% -------------------------------------------------------------------- function Untitled_1_Callback(hObject, eventdata, handles) % hObject handle to Untitled_1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% -------------------------------------------------------------------- function Untitled_3_Callback(hObject, eventdata, handles) % hObject handle to Untitled_3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) axes(handles.axes1); [FileName, PathName] = uiputfile('*.tiff', 'Save As'); Name = fullfile(PathName, FileName); imwrite(handles.figure1, Name, 'tiff');

% -------------------------------------------------------------------- function Untitled_6_Callback(hObject, eventdata, handles) % hObject handle to Untitled_6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) printdlg(handles.figure1)

% -------------------------------------------------------------------- function Untitled_5_Callback(hObject, eventdata, handles) % hObject handle to Untitled_5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],... ['Close ' get(handles.figure1,'Name') '...'],... 'Yes','No','Yes'); if strcmp(selection,'No') return; end

delete(handles.figure1)

% -------------------------------------------------------------------- function Untitled_2_Callback(hObject, eventdata, handles) % hObject handle to Untitled_2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!