Question

In: Mechanical Engineering

Fix the bugs in this matlab program so that it solves. clear clf clc time =...

Fix the bugs in this matlab program so that it solves.

clear
clf
clc
time = linspace(0, 5, 100);
m = 1; k = 100; c = 1; delta = 0.2;
[period, response] = Exmp(m, k, c, delta, time);
plot(time, response)
grid
%Exmp(m, k, c, delta, time)
%
%________________________________________
function [T, x] = Exmp(m, k, c, delta, t)
omega = sqrt(k/m);
cC = 2*m*omega;
if c>= cC
disp('Not an underdamped system')
T = 0; x = 0;
return;
end
% end of if- - - - - - - - - - - - - - - - - - - - -
omegaD = omega*sqrt(1-(c/cC)^2);
T = 2*pi/omegaD;
x = delta*exp((-c.*t)/2*m).*(cos(omegaD*t)+c/(2*m*omegaD).*sin(omegaD*t));
end
% end of the function - - - - - - - - - - - - - - - -

Solutions

Expert Solution

cilck on new symbol on top of left corner

click on function and write as follow

save the function

Now write another script

Press the Run


Related Solutions

Find and fix the compile time bugs in the code at the end of this section....
Find and fix the compile time bugs in the code at the end of this section. Compile time bugs show as errors when you compile, but the Visual Studio IDE also gives you visual clues in the form of red squiggly underlines, as shown here. This assignment is meant to test your attention to detail and strengthen your debugging skills. Here is the code. // Week 4 Assignment-1 // Description: Compile time errors //---------------------------------- //**begin #include files************ #include <iostream> //...
explain this Matlab code and finish its last line. %% clear all; clc; %% % Données...
explain this Matlab code and finish its last line. %% clear all; clc; %% % Données de départ NbrEchParPer=128*2; NbrPer=16; % Ensuite essayer avec 512 T=1e-3; % calcul préliminaire fs=NbrEchParPer/(T); NbrEch=NbrEchParPer*NbrPer; %Axes des temps et des élongations t=[0:NbrEch-1]./fs; x=repmat([ones(1,NbrEchParPer/2),zeros(1,NbrEchParPer/2)] ,1,NbrPer); %représentation des signaux temporels fig1=figure(1);clf; subplot(4,1,[1 2],'Parent',fig1,'Color',[0 0 0]); hold on; plot(t,x,'.b'); plot(t,x,'-g'); ylim([-1,2]); %% %Calcul de la FFT X=fft(x); %Axe des fréquences df=fs/((NbrEch-mod(NbrEch,2))/2); f=[0:NbrEch-1].*df; %représentation du spectre subplot(4,1,3,'Parent',fig1,'Color',[0 0 0]); hold on; plot(f,abs(X),'m'); subplot(4,1,4,'Parent',fig1,'Color',[0 0 0]); hold on; plot(f,abs(X)XXXXXXXXXXXX,'m');
Using this sample matlab code: clear all; clc A= ????????; B= ????????; AUG=[A B]; for L=1:size(A,2)...
Using this sample matlab code: clear all; clc A= ????????; B= ????????; AUG=[A B]; for L=1:size(A,2) %Pivoting starts for k=L:size(AUG,1) for m=k+1:size(AUG,1) if abs(AUG(k,L))<abs(AUG(m,L)) temp=AUG(m,:); AUG(m,:)=?????????; AUG(k,:)=?????????; end end end %Pivoting ends %Gauss Elimination starts for k=L+1:size(AUG,1) AUG(k,:)= ????????????????????????????; AA=AUG(:,1:size(A,2)) BB=AUG(:,size(A,2)+1:end) end %Gauss Elimination ends end b)Write a MATLAB M-file which performs gauss elimination without pivoting step by step and shows the coefficient matrix in each step. Using cond (X, P) calculate the condition number of the final step coefficient...
creat a Matlab simulation the solves the 2D heat equation.
creat a Matlab simulation the solves the 2D heat equation.
Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in...
Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in the 4th edition). Given are the equations for the moment, as a function of x, starting from the leftmost side of the beam with x=0 and ending at the other end of the beam with x=12. This piecewise function together makes up the moment equation for the beam given. 0 ≤ ? ≤ 3 ?(?) = 265? − 5.56?3 , 3 < ? ≤...
So, I have this Matlab program that I have made for a lab, and despite having...
So, I have this Matlab program that I have made for a lab, and despite having different frequencies, when I go to plot them, the graphs look exactly the same. Can someone tell me why that is? I also need to know how to determine the digital frequencies(rad/sec) and how many samples per period of both of the waves? Thank you Code: N = 100; % Total number of time domain samples in simulation. A1 = 1; % Amplitude of...
(IN C) Program Question 2: Write a program that solves for c in the Pythagorean Theorem:...
(IN C) Program Question 2: Write a program that solves for c in the Pythagorean Theorem: a2 + b2 = c2 The user will enter values for a and b, and you will calculate c. All of this code will go in just one source file.
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a 7 day period. Ask the user for the number of bugs collected on each day, and using an accumulator, keep a running total of the number of bugs collected. Display the total number of bugs collected, the count of the number of days, and the average number of bugs collected every day. Create a constant for the number of days the bugs are being...
Write a program in C++ that solves this problem Calculate the area and volume of a...
Write a program in C++ that solves this problem Calculate the area and volume of a sphere problem. Inside a for loop, vary the radius from 10 to 40  with a step or increment of 5 and calculate the area and volume Your radius will be equal to your loop counter. All calculations should have 2 decimal places, but the radius should have zero decimal places and any number of 1,000 or more should have a comma. Print the radius, area,...
Write a simple matlab program to model the position, velocity, and acceleration over time of Ruchardt's...
Write a simple matlab program to model the position, velocity, and acceleration over time of Ruchardt's experiment as a harmonic oscillator.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT