Question

explain all the code and what are they do to the program %Animation axes(handles.axes2) xlabel('length along...

explain all the code and what are they do to the program

%Animation
axes(handles.axes2)

xlabel('length along the beam')
ylabel('deflection')
grid
u=deflection;
plot(ys,repmat(0,size(u)),'r');
axis([0 beam(1) min(deflection) max(deflection)])
drawnow
tt=repmat(0,size(u));
nn=u./1000;
for k = 1:1:1000
tt=tt+nn;

plot(ys,tt,'r');
axis([0 beam(1) min(deflection) max(deflection)])

grid
drawnow
end

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here im explaining above code using comments above each statements

%Animation
axes(handles.axes2)

% we are giving x axis label as length along the beam

xlabel('length along the beam')

% we are giving y axis label as deflection
ylabel('deflection')

% using grid in the graph
grid

% setting u equal to deflection
u=deflection;

% repmat(0,size(u)) returns an array of size u which contains all 0's and plotting using ys as x axis and returned %array as y axis and 'r' specifies to use colour red


plot(ys,repmat(0,size(u)),'r');

% giving x axis range 0 to beam(1) and y axis range min(deflection) to max(deflection)
axis([0 beam(1) min(deflection) max(deflection)])

% procedure draw now
drawnow

% initialising tt with array of 0's of size u
tt=repmat(0,size(u));
nn=u./1000;

%initialising for loop from 1 to 1000 with incrementing 1 step by step
for k = 1:1:1000

% adding nn to tt variable
tt=tt+nn;
% plotting ys as x axis and tt as y axis
plot(ys,tt,'r');

% giving x axis range 0 to beam(1) and y axis range min(deflection) to max(deflection)
axis([0 beam(1) min(deflection) max(deflection)])
%using grid in plot view
grid

% end of drawnow procedure
drawnow
end

Add a comment
Know the answer?
Add Answer to:
explain all the code and what are they do to the program %Animation axes(handles.axes2) xlabel('length along...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • These instructions are written with the assumption that code will be done in matlab. You might fi...

    These instructions are written with the assumption that code will be done in matlab. You might find the following built in commands useful: length, plot, xlabel, ylabel, title, legend, fzero, plot, disp, axis, axes, min, max. 1. A spring-mass system has the following position y(t) and velocity v(t) functions: y(t) = e −0.5t sin(2t) + √ 3e −0.5t cos(2t) v(t) = e −0.5t (2√ 3 − 0.5) sin(2t) − 0.5(4 + √ 3)e −0.5t cos(2t) where the units are in...

  • R1=1e3; C=10e-6; % R=1K ohms, C=1 uF num = -1; den = [R1*C 1]; T=[0:.001:5]; W=...

    R1=1e3; C=10e-6; % R=1K ohms, C=1 uF num = -1; den = [R1*C 1]; T=[0:.001:5]; W= logspace(1,3,20) for i= 1:length(W)   w=W(i); u=cos(w*T); y=lsim(H1,u,T); gain(i)=max(y)/max(u); plot(T,u,T,y), grid, title(['x(t) & y(t): w = ' num2str(w)]) shg pause end semilogx(W,20*log10(gain)),grid, title('Frequency Response gain H1(w)'); xlabel(‘Freq (r/s)’) ylabel(‘db(H1)’) shg How can this code sweep a sine wave? And measure dB to get a frequency response

  • Hello. I need help modifying this MatLab code. This is a basic slider-crank animation. the current...

    Hello. I need help modifying this MatLab code. This is a basic slider-crank animation. the current program stops the animation and then has the crank move backward. I need the crank to instead to move in full 360 degrees circular motion. Exactly like how a slide-crank mechanism works in real life. thank you and here is the code. %%Code Begins Here%% L1=0.2; L2=0.45; W=0.5; tt=linspace(0,15); for i=1:length(tt)     x2=@(t) L2+L1*sin(W*t);     y2=0;     X2=x2(tt(i));     Y2=y2;     sol= fsolve(@(x,x2,y2) root2d(x,X2,Y2),...

  • Hello, i have this matlab code where i have to track a red ball from and...

    Hello, i have this matlab code where i have to track a red ball from and uploaded video, and plot its direction in x-y direction My Question is how can i add x vs time plot and y vs time plot in this code. Thank you if exist('V','var') delete(V); end clear;clc; V=VideoReader('video.mp4'); figure(1); x=[];y=[]; i=1; while hasFrame(V) J=readFrame(V); figure(1);imshow(J);title(['Frame No. ',num2str(i)]); if (i>=28 && i<=132) bw=J(:,:,1)>200 & J(:,:,2)<80 & J(:,:,3)<80; bw=imfill(bw,'holes'); A=regionprops(bw,'Centroid'); x(end+1)=A.Centroid(1); y(end+1)=A.Centroid(2); hold on; plot(x,y,'*k');hold off; end i=i+1;...

  • These instructions are written with the assumption that code will be done in matlab. You might fi...

    These instructions are written with the assumption that code will be done in matlab. You might find the following built in commands useful: length, plot, xlabel, ylabel, title, legend, fzero, plot, disp, axis, axes, min, max. 2. Numerical Integration (Quadrature). Write FOUR of your own numerical integration routines. One should use left-end, right-end, or mid-points, another should use the trapezoid method, another should use Simpson’s method, and the fourth should use either Guassian Quadrature or Romberg’s method. Use your four...

  • need help with this graph in matlab here is my prior code and graph which the...

    need help with this graph in matlab here is my prior code and graph which the question is referring too Using Matlab, write a program to print out a graph of HP VS Velocity over the range of 0 to 250 mph Details on the organization of your graph are given in the following paragraph The graph you develop should be presented in units of hp and mph it should have a title grid lines, and axis labels with units...

  • please help me with this MATLAB CODE and explain to me what each line does and...

    please help me with this MATLAB CODE and explain to me what each line does and what is used for? leave your comments as words, not as pictures. ..................................................................................................................................................................... clear all; close all; % For a script file, you better start with clear all and close all                        % However, for a fucntion, you better NOT to start                        % with them %% End of cell mode example %% Plot function t = 0:0.1:5; x1 = sin(2*5*t); x2 = cos(3*7*t);...

  • MATLAB code for a double pendulum. Please explain each lines for these codes pls. -------------------------------------...

    MATLAB code for a double pendulum. Please explain each lines for these codes pls. ---------------------------------------------------------------------------- clc close all clear all %---------Parameters------------------------------------------------------ L1=1; L2=1 ; M_1=2 ; M_2=1; G=9.8; %---------initial condition----------------------------------------------- tspan=30; theta1=3; theta1_prime=0; theta2=2.5; theta2_prime=0; y0=[theta1 theta1_prime theta2 theta2_prime]; [t,y]=ode45(@pend, [0 ,tspan],[ 3 0 2 0]); %---position of mass 1 and mass 2---------------------------------------- x1=L1*sin(y(:,1)); y1=-L1*cos(y(:,1)); x2=L1*sin(y(:,1))+l2*sin(y(:,3)); y2=-L1*cos(y(:,1))-l2*cos(y(:,3)); %------visualizing the result--------------------------------------------- figure(1) plot(x1,y1,'linewidth',2) hold on plot(x2,y2,'r','linewidth',2) h=gca; get(h,'fontSize') set(h,'fontSize',14) xlabel('X','fontSize',14); ylabel('Y','fontSize',14); title('Chaotic Double Pendulum','fontsize',14) fh = figure(1); set(fh, 'color', 'white'); figure(2)...

  • EMT 101- Engineering Programming Homework 3 Deflection of an I-Beam(100 %) You are to develop a program that calculates and plots the vertical deflection of a beam subjected to a force acting on it...

    EMT 101- Engineering Programming Homework 3 Deflection of an I-Beam(100 %) You are to develop a program that calculates and plots the vertical deflection of a beam subjected to a force acting on it as given in Figure 1. The I-Beam has length, L 2m with its left end fixed at the wall (no deflection at wall) The right end of the beam is applied with a vertical load force P with a vertical deflection function (3L -a) EI wherer...

  • why will my function not run in the main code ##This is the main code## %%...

    why will my function not run in the main code ##This is the main code## %% Problem IV %% % ON SEPARATE M FILE ellipsoid_volume(8,17,"Volume versus depth for an ellipsoid") ## This is the function code## % This program calls the following user-written functions % 1. ellipsoid_volume    % Problem 1 - Calculate volume of ellipsoid shaped tank. figure(1) ellipsoid_volume(3,12,'Volume versus depth for an ellipsoid') function ellipsoid_volume(a,b,plot_title,units) %volume of horizontal ellipsoid %inputs: %a - vertical semi-axis %b - horizontal radius...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT