Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Square Wave as ODE Forcing Function

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-18-2021
09:12 PM

04-18-2021
09:12 PM

hi,

i wanted to use a square wave to drive a mass spring damper system. i usually use the state space solver, as it has worked better than the other solvers. however, in this case, i get an error. note, the worksheet isn't fully setup yet, due to the error. i was trying to make an example, since there aren't any quick sheets for a square wave.

thanks,

anthony

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-18-2021
11:44 PM

04-18-2021
11:44 PM

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-18-2021
10:48 PM

04-18-2021
10:48 PM

Re: Square Wave as ODE Forcing Function

Hi,

See enclosed working file with comment in blue.

Cheers

Terry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-18-2021
11:44 PM

04-18-2021
11:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-19-2021
05:19 AM

04-19-2021
05:19 AM

Re: Square Wave as ODE Forcing Function

hi terry,

thanks. your second post is what i was going for. that's a strange quirk. i tried something similar, before i posted the question, but it didn't work for me. it's working now though. you're help has allowed me to move forward with the example. once i get it finished, i'll post the file.

anthony

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-19-2021
09:19 AM

04-19-2021
09:19 AM

Re: Square Wave as ODE Forcing Function

so i'm still having some weird things happen. i attached an updated file. there are three questions in the file.

the state space solver help doesn't say what the last column of the solution is. i'm thinking it might be velocity but i'm not sure about that. i can't plot the square wave using time for some reason. also if you try to see what it is, it comes back as a constant, which makes no sense.

to avoid confusion from my original post, i made u1 the cosine wave and u2 the square wave. there is no problem with the cosine wave. the point of this example was to try and use a square wave. luc had previously posted an interesting solution for creating a square wave. i made some slight modifications to what luc posted. however, there seems to be a lot of problems actually using the square wave with the state space solver.

i figured out the answer to two of the questions. for some reason, you have to use the vectorize feature on the square wave but not the cosine wave. so the only remaining question is what is the last column of the state space solution matrix.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-19-2021
01:35 PM

04-19-2021
01:35 PM

Re: Square Wave as ODE Forcing Function

Hi,

Plot u2 now OK.

u2(t) is not a constant?

not sure about velocity?

enclosed file.

Cheers

Terry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-19-2021
08:13 PM

04-19-2021
08:13 PM

Re: Square Wave as ODE Forcing Function

it looks like the last column of the state space output might be velocity. however, i get a lot of error when using the time and displacement output to calculate velocity and acceleration. if the last column is velocity, there doesn't seem to be a way to confirm it. i'm trying odesolve instead. it makes it easy to calculate v, a, and kinetic energy. however, it also introduces other problems. lastly, the state space results and the odesolve results are drastically different. so running into a lot of problems.

update; i found the problem with the state space solver not matching odesolve. it had to do with how the quick sheets i used were setup. there is still the problem of the velocity from the state space solver being different than if you manually calculate it. there is no information on how it is calculated. therefore, odesolve would be better in that regard.