cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

SOLVED
Moonstone

Square Wave as ODE Forcing Function

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

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

And another.

6 REPLIES 6

Re: Square Wave as ODE Forcing Function

Hi,

See enclosed working file with comment in blue.

Cheers

Terry

Hi,

And another.

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

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.

Re: Square Wave as ODE Forcing Function

Hi,

Plot u2 now OK.

u2(t) is not a constant?

enclosed file.

Cheers

Terry

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.

Announcements
Check out the latest