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

How do I use variables? #18

Open
dds852456tw opened this issue Apr 24, 2024 · 1 comment
Open

How do I use variables? #18

dds852456tw opened this issue Apr 24, 2024 · 1 comment

Comments

@dds852456tw
Copy link

My requirement is to input a double array and then do FFT using Octave, but I don’t know how to give the input to Octave.
by the way FFT output format is complex , can i use AsVector(); ??

public static void FFT_Octave(double[] signal)
{
double fre, amp;

using (var octave = new OctaveContext())
{
    var input = octave.Execute(signal.ToOctave()); // [??????]

    var vectorResult = octave
        .Execute("fft(input)")
        .AsVector();
}

}

@dds852456tw
Copy link
Author

dds852456tw commented Apr 25, 2024

Hi I found the solution below, but the result is string not array or another type,
I referred to the test examples and did not find any suitable ones for process the complex.

octave

>> fft([1 2 3 4 5])
ans =

   15.0000 +       0i   -2.5000 +  3.4410i   -2.5000 +  0.8123i   -2.5000 -  0.8123i   -2.5000 -  3.4410i

c#

FFT_Octave([0, 1, 2, 3, 4, 5]);

public static void FFT_Octave(double[] signal)
{
    double fre, amp;

    using (var octave = new OctaveContext())
    {
        string input = signal.ToOctave(); // [??????]

        string cmd = "fft(" + input + ")";

        var vectorResult = octave.Execute(cmd);
    }
}

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

1 participant