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...
Python 3 Fix the code so everytime i hit clear the calendar resets to the current...
Python 3 Fix the code so everytime i hit clear the calendar resets to the current date in case it was modified Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries...
Python 3 Fix the code so everytime i hit clear the calendar resets to the current...
Python 3 Fix the code so everytime i hit clear the calendar resets to the current date in case it was modified Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries...
Python 3 Fix the code so everytime i hit clear the calendar resets to the current...
Python 3 Fix the code so everytime i hit clear the calendar resets to the current date in case it was modified Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries...
Python 3 Fix the code so the program reads the file and see if the bar...
Python 3 Fix the code so the program reads the file and see if the bar code was already inputted 3 times if so, it ishows a warning indicating that the item was already tested 3 times Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window,...
using matlab Show the two formals or figures in time domin and z dominclc clear all...
using matlab Show the two formals or figures in time domin and z dominclc clear all b=[1,-4,5] a=[1,-6,11,-6] [R,P,C]=residuez(b,a) Ez=tf(b,a,1,'variable','z') zplane(b,a)
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...
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