triforcely / octave.net Goto Github PK
View Code? Open in Web Editor NEWπ More than cross-platform Octave process wrapper π¬
License: MIT License
π More than cross-platform Octave process wrapper π¬
License: MIT License
I run the following commands on Octave-GUI, everything works fine and shows a 3D pattern interface. If I execute with Octave.NET, there is no graphical interface displayed.
[x, y, z] = sphere (40);
surf (3x, 3y, 3*z);
axis equal;
title ("sphere of radius 3");
Hi, @CptWesley , @triforcely
How Can I save my octave variable?
using Octave.NET;
double[][] bb;
using(var oct1= new OctaveContext())
{
oct1.Execute("pkg load image;");
double[][] aa= oct1
.Execute("peaks(64);")
.AsMatrix();
bb=aa;
}
Thanks ~!
from @bemoregt
Hello I want Use it in My WebSite
so i print it to file
but it says 'OctaveScriptError: error: sq_string cannot be indexed with'
this is my code
var script = @"
x = -10:0.1:10;
y = sin (x);
handle = plot (x, y);
print('"+ uid + "'.png','-dpng') ";
var a= octave.Execute(script, int.MaxValue);
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();
}
}
using System;
using System.IO;
using Octave.NET;
namespace ConsoleOctave1
{
class Program
{
static void Main(string[] args)
{
using (var octave = new OctaveContext())
{
octave.Execute("pkg load image;");
double[][] result = octave
.Execute("aa=peaks(256)")
.AsMatrix();// 10
Console.WriteLine(result[1][1].ToString());
StreamWriter sw1;
sw1 = new StreamWriter("data.txt");
for (int i = 0; i < 256; i++)
{
for (int j = 0; j < 256; j++)
{
sw1.WriteLine(result[i][j].ToString());
}
}
sw1.Dispose();
}//using Octave
}// method
}// class
And Now, I want saving image from octave.
How can I save my octave image using Octave.net?
I run the following commands on Octave-GUI, everything works fine and shows a 3D pattern interface. If I execute with Octave.NET, there is no graphical interface displayed.
[x, y, z] = sphere (40);
surf (3x, 3y, 3*z);
axis equal;
title ("sphere of radius 3");
Adding the bin folder to system path was working fine with me, but I need to use it through code for deployment purposes, but it won't work correctly with me, it always through an exception that I've added details below.
My usage goes like that
OctaveContext.OctaveSettings.OctaveCliPath = @"D:\InstalledPrograms\Octave\Octave-5.1.0.0\mingw64\bin\"; // add octave logic using (var octave = new OctaveContext()) { octave.Execute("pkg load image;");
I've tried to change the path several changes by adding the octave-cli file name with and without the .exe extension. i've copied the file into my project path, but failed in all nonetheless.
How to specify path to octave-cli binary in my code? I'm using .Net framework 4.7 and 4.6.1 in my project.
Thank you so much.
Exception:
{ "Message": "An error has occurred.", "ExceptionMessage": "Unable to run 'octave-cli' executable. Make sure that it exists and/or is added to environment PATH variable.", "ExceptionType": "System.Exception", "StackTrace": " at Octave.NET.OctaveProcess..ctor(String octaveCliPath)\r\n .... "InnerException": { "Message": "An error has occurred.", "ExceptionMessage": "The system cannot find the file specified", "ExceptionType": "System.ComponentModel.Win32Exception", "StackTrace": " at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)\r\n at Octave.NET.OctaveProcess..ctor(String octaveCliPath)" }
I have tested your solution with Octave 7.2.0 and you should know the application name 'octave-cli.exe' has changed to 'octave-launch.exe'. Also notice that 'octave-launch.exe' is now used for both GUI and CLI by using arguments:
GUI: "C:\Program Files\GNU Octave\Octave-7.2.0\octave-launch.exe" --gui
CLI: "C:\Program Files\GNU Octave\Octave-7.2.0\octave-launch.exe" --no-gui
In OctaveGlobal.cs the application name is changed:
private const string OctaveExecutable = "octave-launch";
In OctaveProcess.cs the Arguments "--no-gui" is added:
StartInfo = new ProcessStartInfo()
{
FileName = octaveCliPath,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
Arguments = "--no-gui"
};
I was pleased to find this program, as it is exactly what I was searching for to solve a problem.
One issue I notice: the code works perfectly when I include Octave in my path. However, I do not think it is actually possible to specify the Octave executable through the code. This is because the OctaveContext creates the processPool item in its constructor, before anyone can have a chance to modify the OctaveSettings object. Perhaps it is possible to overload the constructor, and have an option to pass a customized OctaveSettings?
my solution:
but its not efficient, lose interaction , and it will open new window for plot (so i must close it manually or by code 'close'),
so i want to ask Is there better solution for it ?
how does the website accomplish it
thank you~~~~
I am having trouble running the example project.
I have Octave 4.4.1 installed as I can't find the links for 4.4.0 and have added "C:\Octave\Octave-4.4.1\bin" to the System Path variable.
The path never gets loaded in the octave object and it's causing to throw an exception.
If I manually specify the path to the bin, the result is the same.
I met this error when run this code:
using (var octave = new OctaveContext())
{
// Note: your octave-cli must support some plot backend, in case of problems investigate manually in octave-cli
var script = @"
x = -10:0.1:10;
y = sin (x);
filename= 'aa.txt';
save(filename, y);
handle = plot (x, y);
title (""Hello from C#"");
xlabel (""x"");
ylabel (""sin (x)"");
Error: "error: : all arguments must be strings\n"
What's wrong to me?
Thanks.
from @bemoregt.
Hi,all:
I have defined a function in script, like:
disp("Running...") function result = myrand(n, t, p, d) a = 200 * t + p; big_rand = a * n; result = big_rand / 10**d; return;endfunction mrand = myrand(5379, 0, 91, 4)
the script can correct execute in octave, but when call:
octave.Execute(script)
will show error : "error: 'myrand' undefined near line 1, column 9\r\n"
how defined a function in script? thanks
Hi there,
I was wondering what would be the compatibility with the latest Octave 6.x releases (6.2.0 at the time of writing)?
Are breaking changes usually expected with major releases (in essence what happened to make it compatible with 5.x two years ago)?
Regards
I have met this error when run.
"error: : all arguments must be strings\n"
What's wrong to me?
using System;
using System.IO;
using Octave.NET;
namespace ConsoleOctave1
{
class Program
{
static void Main(string[] args)
{
using (var octave = new OctaveContext())
{
octave.Execute("pkg load image;");
double[][] result = octave
.Execute("aa=peaks(256)")
.AsMatrix();// 10
double[][] bb = octave
.Execute("bb=aa.+1")
.AsMatrix();// 10
var cc = octave
.Execute("f1='aa.mat'")
.AsSpan();
var dd = octave
.Execute("save(f1, bb);") <------ Error occurs at here. ###########
.AsMemory();// 10
Console.WriteLine(bb[1][1].ToString());
StreamWriter sw1;
sw1 = new StreamWriter("data.txt");
for (int i = 0; i < 256; i++)
{
for (int j = 0; j < 256; j++)
{
sw1.WriteLine(bb[i][j].ToString());
}
}
sw1.Dispose();
}//using Octave
}// method
}// class
}// namespace_
Thanks in advance.
Hi, I am having issue installing from NuGet:
Severity Code Description Project File Line Suppression State
Error Could not install package 'Octave.NET 1.1.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.