Matlab: Numerically Integrate and Plot Response of Underdamped System

Click For Summary

Discussion Overview

The discussion revolves around a homework problem involving the numerical integration and plotting of the response of an underdamped system using MATLAB. The system parameters include mass, spring constant, damping coefficient, initial conditions, and an applied force. Participants are seeking to troubleshoot MATLAB code related to this problem.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • The initial post outlines the parameters of the underdamped system and presents MATLAB code intended to solve the problem using state space representation.
  • The poster encounters an error when executing the lsim function, suggesting a potential issue with the syntax or the handling of initial conditions.
  • One participant requests clarification on what is meant by "Matlab routines" and emphasizes the need for more details about the code used to diagnose the problem effectively.
  • Another participant reiterates the request for a complete view of the MATLAB programming to better understand the context of the error message received.

Areas of Agreement / Disagreement

Participants generally agree that more information is needed to assist with troubleshooting the MATLAB code. There is no consensus on the specific cause of the error, as the discussion is still in the early stages of clarification.

Contextual Notes

Participants have noted the importance of providing complete code to identify issues, but the initial post does not include all relevant details, which may hinder effective troubleshooting.

Northbysouth
Messages
241
Reaction score
2

Homework Statement


Numerically integrate and plot the response of an underdamped system determined by m= 100 kg,
k= 20,000 N/m, and c = 200 kg/s, subject to the initial conditions of x0 = 0.01 m and v0 = 0.1 m/s, and the applied force F(t)=150cos(5t). Then plot the exact response.

Homework Equations


The Attempt at a Solution



I've been trying to use MATLAB to solve this question, but I'm having a little trouble. I started by defining the variables and the time durations. I was attempting to use the state space form to solve the problem, hence I defined matrices A, B, C and D

Code:
m=100; k=20000; c=200; x0=0.01; v0=0.1; f0=150; w=5;
F0=f0/m;
t=[0:0.1:5];

A=[0 1; -k/m -c/m];
B=[0; 1];

C=[0 1;1 0];

D=[];

sys=ss(A,B,C,D);

u=F0*cos(w*t);

lsim(sys,u,t,x0,v0)

[code]

When I run the code I get:

Error using DynamicSystem/lsim (line 98)
Invalid syntax for time or frequency response command. See command help for more
information.

Error in ME_3504_chapter2_80a (line 17)
lsim(sys,u,t,x0,v0) 

I don't understand what the problem is. I can see it's to do with lsim, but I'm not sure how to fix it. I suspect that it may have something to do with the initial conditions x0 and v0.

Any advice would be greatly appreciated. Thank you
 
Last edited:
Physics news on Phys.org
If you have written Matlab routines to solve your problem, please share them so that we can make sense of the errors you have gotten. Don't forget to use
Code:
 tags for the source.
 
I've added the
Code:
 tags but I'm not sure what you mean by Matlab routines.
 
Northbysouth said:
I've added the
Code:
 tags but I'm not sure what you mean by Matlab routines.[/QUOTE]

It's not clear if you have written a program in Matlab to solve your problem or you are trying to do it interactively.  You know what you have done; we don't, so we are depending on you to provide the details.

What you have shown in the OP obviously doesn't have a line 98.  Show all the MATLAB programming you are using to solve the problem.  The [CODE] tags should go around that when you attach it as a reply.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K