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...
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 <...
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 =...
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...
Python programming: can someone please fix my code to get it to work correctly? The program...
Python programming: can someone please fix my code to get it to work correctly? The program should print "car already started" if you try to start the car twice. And, should print "Car is already stopped" if you try to stop the car twice. Please add comments to explain why my code isn't working. Thanks! # Program goals: # To simulate a car game. Focus is to build the engine for this game. # When we run the program, it...
Python 3 Fix the code so i can make the window larger or smaller and the...
Python 3 Fix the code so i can make the window larger or smaller and the fields adjusts everytime according to the window size import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook window = tk.Tk() window.title("daily logs") # window.resizable(0,0) # 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)...
Here is my java code. It works and has the correct output, but I need to...
Here is my java code. It works and has the correct output, but I need to add a file and I am not sure how. I cannot use the FileNotFoundException. Please help! import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Exercise { public static void main(String[] args) { Scanner input=new Scanner(System.in); int[] WordsCharsLetters = {0,0,0}; while(input.hasNext()) { String sentence=input.nextLine(); if(sentence!=null&&sentence.length()>0){ WordsCharsLetters[0] += calculateAndPrintChars(sentence)[0]; WordsCharsLetters[1] += calculateAndPrintChars(sentence)[1]; WordsCharsLetters[2] += calculateAndPrintChars(sentence)[2]; } else break; } input.close(); System.out.println("Words: " + WordsCharsLetters[0]); System.out.println("Characters: "...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT