Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c2d not working with method input #873

Closed
fibonatic opened this issue Sep 18, 2023 · 4 comments
Closed

c2d not working with method input #873

fibonatic opened this issue Sep 18, 2023 · 4 comments

Comments

@fibonatic
Copy link

fibonatic commented Sep 18, 2023

When I attempt to specify which discretization method I want to use, for example:
Gd = c2d(G::TransferFunction{<:Continuous}, Ts, method=:zoh)
I get the error:
c2d_x0map(::AbstractStateSpace{<:Continuous}, ::Real) got unsupported keyword argument "method"

I am using Julia 1.9.3 and just installed ControlSystems.jl today.
I also get the same error in Julia 1.8.5

@baggepinnen
Copy link
Member

This appears to work for me

julia> G = tf(1.0, [1, 1])
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
   1.0
----------
1.0s + 1.0

Continuous-time transfer function model

julia> c2d(G, 0.1, :zoh)
TransferFunction{Discrete{Float64}, ControlSystemsBase.SisoRational{Float64}}
   0.09516258196404037
-------------------------
1.0z - 0.9048374180359594

Sample Time: 0.1 (seconds)
Discrete-time transfer function model

Are you trying to use method as a keyword argument? It's a regular positional argument.

@baggepinnen
Copy link
Member

On a side note, are you the user handle fibonatic on the control discord? If so, we spoke about coherence functions this morning ;)

@fibonatic
Copy link
Author

Yes, I am currently busy writing some test code, but it has been a while since I used Julia. And I was indeed using method=:zoh as input argument. Without the method= it is indeed working OK.
Thanks!

@baggepinnen
Copy link
Member

baggepinnen commented Sep 18, 2023

You might have been confused by the fact that the method argument hasa default value indicated by the signature in the docstring

    sysd = c2d(sys::AbstractStateSpace{<:Continuous}, Ts, method=:zoh; w_prewarp=0)
    Gd = c2d(G::TransferFunction{<:Continuous}, Ts, method=:zoh)

Note the difference between the two method signatures, the ; denotes the delimitation between positional arguments and keyword arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants