Question

In: Computer Science

please correct the error and fix this code: (i need this work and present 3 graphs):...

please correct the error and fix this code: (i need this work and present 3 graphs):

Sampling_Rate = 0.00004; % which means one data point every 0.001 sec
Total_Time = 0:Sampling_Rate:1; % An array for time from 0 to 1 sec with 0.01 sec increment

Omega = 49.11; % in [rad/s]
zeta=0.0542; %unitless
Omega_d=49.03; % in [rad/s]
Displacement_Amplitude = 6.009; % in [mm]
Phase_Angle = 1.52; % in [rad]
Total_No_of_Points = length(Total_Time); % equal to the number of points in the "Total_Time" array

for i = 1: Total_No_of_Points
X(i) = Displacement_Amplitude* exp(-zeta*Omega*Total_Time(i)) * sin(Omega_d * Total_Time(i) + Phase_Angle); % Position Equation
V(i) = Displacement_Amplitude* exp(-zeta*Omega*Total_Time(i)) *( -zeta*Omega*sin(Omega_d * Total_Time(i) + Phase_Angle)+Omega_d * cos(Omega_d * Total_Time(i) + Phase_Angle)); % Velocity Equation
A(i) = -1 * Displacement_Amplitude * exp(-zeta*Omega*Total_Time(i))( zeta^2*Omega^2*sin(Omega_d * Total_Time(i)) - 2*zeta*Omega*Omega_d cos(Omega_d*Total_Time(i) + Phase_Angle)-2*Omega_d^2*sin(Omega_d*Total_Time(i) + Phase_Angle)); % Acceleration Equation
end

figure,
subplot (311);
plot (Total_Time,X,'.b');
title('Free Undamped Oscillation');
ylabel ('x(t) [mm]');
subplot (312);
plot (Total_Time,V,'.r');
ylabel ('x^.(t) [mm/s]');
subplot (313);
plot (Total_Time,A,'.k');
xlabel ('t [s]');
ylabel ('x^.^.(t) [mm/s^2]');

Solutions

Expert Solution

Code has been cleaned according to the python compiler .

import matplotlib.pyplot as plt

import math

import numpy as np


Sampling_Rate = 0.00004  #; % which means one data point every 0.001 sec

i=0

Total_Time = []

while(i<=1):     #; % An array for time from 0 to 1 sec with 0.01 sec increment

  Total_Time.append(i)    

  i = i + 0.01


Omega = 49.11     #; % in [rad/s]

zeta=0.0542       #; %unitless

Omega_d=49.03       #; % in [rad/s]

Displacement_Amplitude = 6.009     #; % in [mm]

Phase_Angle = 1.52     #; % in [rad]

Total_No_of_Points = len(Total_Time)         #; % equal to the number of points in the "Total_Time" array

X = []

V = []

A = []

for i in range(Total_No_of_Points):     #= 1: Total_No_of_Points

  X.append(Displacement_Amplitude* math.exp(-zeta*Omega*Total_Time[i]) * np.sin(Omega_d * Total_Time[i] + Phase_Angle) )     #; % Position Equation

  V.append(Displacement_Amplitude* math.exp(-zeta*Omega*Total_Time[i]) *( -zeta*Omega*np.sin(Omega_d * Total_Time[i] + Phase_Angle)+Omega_d * np.cos(Omega_d * Total_Time[i] + Phase_Angle)))      #; % Velocity Equation

  A.append((-1) * Displacement_Amplitude * math.exp(-zeta*Omega*Total_Time[i])*( (zeta**2)*(Omega**2)*np.sin(Omega_d * Total_Time[i]) -

                    2*zeta*Omega*Omega_d *np.cos(Omega_d*Total_Time[i] +

                    Phase_Angle)-2*(Omega_d**2)*np.sin(Omega_d*Total_Time[i] + Phase_Angle)))    #; % Acceleration Equation

  

fig = plt.figure()

fig.add_subplot (311)

plt.plot(Total_Time,X,'.b')

plt.title('Free Undamped Oscillation')

plt.ylabel ('x(t) [mm]')

fig.add_subplot (312)

plt.plot (Total_Time,V,'.r')

plt.ylabel ('x^.(t) [mm/s]')

fig.add_subplot (313);

plt.plot (Total_Time,A,'.k');

plt.xlabel ('t [s]');

plt.ylabel ('x^.^.(t) [mm/s^2]');


Related Solutions

Hello I have this error in the code, I do not know how to fix it....
Hello I have this error in the code, I do not know how to fix it. It is written in C++ using a Eclipse IDE Error: libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string bus.h =========== #pragma once #include using namespace std; class Bus { private:    string BusId; // bus ID    string Manufacturer; // manufacturer of the bus    int BusCapacity; // bus capacity    int Mileage; // mileage of bus    char Status; // current status...
I need to fix this code, and could you please tell me what was the problem...
I need to fix this code, and could you please tell me what was the problem options 1 and 9 don't work #include <stdio.h> #include <time.h> #include <stdlib.h> // generate a random integer between lower and upper values int GenerateRandomInt(int lower, int upper){     int num =(rand()% (upper - lower+1))+lower;     return num; } // use random numbers to set the values of the matrix void InitializeMatrix(int row, int column, int dimension, int mat[][dimension]){     for(int i =0; i<row; i++){...
I'm getting an error message with this code and I don't know how to fix it...
I'm getting an error message with this code and I don't know how to fix it The ones highlighted give me error message both having to deal Scanner input string being converted to an int. I tried changing the input variable to inputText because the user will input a number and not a character or any words. So what can I do to deal with this import java.util.Scanner; public class Project4 { /** * @param args the command line arguments...
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from...
Python 3 Fix the code and rovide the correct indentation 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, 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 barcode = tk.Entry(window) product = tk.Entry(window) money =...
Please fix this code I am having issues compiling it all together there is 3 codes...
Please fix this code I am having issues compiling it all together there is 3 codes here and it's giving me errors in my main method..... I feel like it might be something simple but I can't seem to find it. package assignement2; import java.util.ArrayList; import java.util.Scanner; public class reg1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of items: "); int number = input.nextInt(); input.nextLine(); for (int i = 0; i <...
Need to fix this code for tc -tac-toe game .. see the code below and fix...
Need to fix this code for tc -tac-toe game .. see the code below and fix it #include <iostream> using namespace std; void display_board(); void player_turn(); bool gameover (); char turn ; bool draw = false; char board [3][3] = { {'1', '2', '3'}, { '4', '5', '6'}, { '7', '8', '9'}}; int main() { cout << " Lets play Tc- Tac- toe game " <<endl ; cout << " Player 1 [X] ----- player 2 [0] " <<endl <<endl;...
Please provide assistance to fix the segmentation fault error I am receiving and solve the following...
Please provide assistance to fix the segmentation fault error I am receiving and solve the following problem I am working on: My goal is to build a Trie data structure in C++ that can do the following: - Capable to insert any given dictionary .txt file filled with a single word per line (i.e. file includes ant, bat, car, desk, etc.) into the Trie. A sample dictionary file that I'm working with can be found at http://txt.do/1pht5 - Prompts the...
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile and Execute. The...
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile and Execute. The project is below, I have supplied the code and I'm getting an error in SavingsAccount.h file. 17   5   C:\Users\adam.brunell\Documents\Classes\C++\Week4\SavingsAccount.h   [Error] 'SavingsAccount::SavingsAccount(std::string, double, double)' is protected A.Assume i.SavingsAccount: Assume an Interest Rate of 0.03 ii.HighInterestSavings: Assume an Interest Rate of 0.05, Minimum Balance = $2500 iii.NoServiceChargeChecking: Assume an Interest Rate = 0.02, Minimum of Balance = $1000 iv.ServiceChargeChecking – Assume account service charge = $10,...
Need the correct line of code for c program to solve  this equation . i is a...
Need the correct line of code for c program to solve  this equation . i is a value that the program all ready calculates from user imput. t i = (x*1000)+(y*500)+(z*250
Hi there, I need mpx2100ap arduino code do I need an amplifier to make this work...
Hi there, I need mpx2100ap arduino code do I need an amplifier to make this work ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT