octave

How to embed the GNU Octave in C/C++ program?

浪尽此生 提交于 2019-11-27 13:45:34
I want to calculate some matrix algorithms using the GNU Octave library. I know I can use C/C++ API of Octave for basic use. However the method I want to use is not in the default packages of Octave. So how to use Octave's control package in the C/C++ program? Appleman1234 Something like this embed.cpp #include <iostream> #include <octave/octave.h> int main(int argc,char* argv) { int embedded; octave_main(argc,argv,embedded=0); return embedded; } Then mkoctfile embed.cpp --link-stand-alone -o embed in order to make a standalone executable. To call octave functions whether they are provided by

What are the second-moments of a region?

喜你入骨 提交于 2019-11-27 13:15:58
问题 I'm currently working on replicating some of the functionality of Matlab's regionprops function in Octave. However, I have a bit of a hangup on a subset of the functionality. The 'Eccentricity', 'MajorAxisLength', 'MinorAxisLength' and 'Orientation' properties are my sticking point. In the documentation, they all derive from "...the ellipse that has the same second-moments as the region." So my question is, what are these second-moments, and how do I find them? I was looking at this link:

How do I create a simple Octave distributable without installing Octave

北慕城南 提交于 2019-11-27 11:57:23
The Octave documentation on this subject is both intimidating and sparse. I did not know where else to document the solution I found, so I am posting here. I apologize if that's inappropriate, but I want to help the next guy. The following solution is for a simple windows distributable. Use Case: A solution is developed in Octave 3.2.4, and needs to be distributed to end-users with few computer skills. Installing and explaining Octave is impossible, the solution must be "one-click" or "brain-dead-simple." Known Issues: imread fails in 3.2.4 because file_in_path.m is wrong. You will need to

octave基本语法

早过忘川 提交于 2019-11-27 09:45:22
基本运算 octave:3> 5+6 ans = 11 octave:4> 3-2 ans = 1 octave:5> 8*9 ans = 72 octave:6> 8/4 ans = 2 octave:7> 6/4 ans = 1.5000 octave:8> 2^6 ans = 64 octave:9> 注释:% 表示注释符号 octave:9> 1 == 2 %false ans = 0 octave:10> 1~=2 ans = 1 octave:11> 1 && 0 % AND ans = 0 octave:12> 1 || 0 % OR ans = 1 octave:13> xor(1,0) % 异或 ans = 1 octave:14> 改变提示符: octave:14> PS1('>> '); ,' ' 内表示所选提示符 >> a=3 a = 3 >> a=3;%加上分号将不会显示 >> a a = 3 >> a=3; >> a=2 a = 2 >> a=2;%加上分号将不会显示 >> b='hi' b = hi >> c=(3>=1) c = 1 >> a=pi a = 3.1416 >> disp(a) 3.1416 >> disp(sprintf('2 decimals: %0.2f',a)) % 类似于C语言的输出语句 decimals: 3.14

Sweep / chirp signal ends at incorrect frequency

无人久伴 提交于 2019-11-27 09:35:37
I'm creating a sweep / chirp signal using matlab / octave and my ending signal seems to be ending at the wrong frequency. How can I fix it so that the signal ends at the correct frequency. PS: I can't use the chirp command in octave because I'm creating a chirp / sweep signal using a specific equation. Example code with simple equation. and plot of problem %test sweep / chirp clear all,clc freq1=20; %start freq freq2=200; %end freq fs=44100; dur=1; %duration of signal in seconds t = linspace(0,2*pi,fs*dur); f=freq1:(freq2-freq1)/length(t):freq2-(freq2-freq1)/length(t); %20:(200-20)/lenght(t)

gradient descent seems to fail

不打扰是莪最后的温柔 提交于 2019-11-27 09:32:36
问题 I implemented a gradient descent algorithm to minimize a cost function in order to gain a hypothesis for determining whether an image has a good quality. I did that in Octave. The idea is somehow based on the algorithm from the machine learning class by Andrew Ng Therefore I have 880 values "y" that contains values from 0.5 to ~12. And I have 880 values from 50 to 300 in "X" that should predict the image's quality. Sadly the algorithm seems to fail, after some iterations the value for theta

What is your favourite MATLAB/Octave programming trick? [closed]

最后都变了- 提交于 2019-11-27 08:55:23
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not

Octave: How to prevent plot window from closing itself?

我的梦境 提交于 2019-11-27 08:04:46
问题 From the octave CLI or octave GUI, if I run plot([1,2,3],[1,4,9]) it will display a plot window that I can look at and interact with. If however I create file myPlot.m with the same command as content plot([1,2,3],[1,4,9]) and that I run it with octave myPlot.m then I can briefly see the plot window appear for a fraction of a second and immediatly close itself. How can I prevent this window from closing itself? Octave 4.2.2 Ubuntu 18.04 回答1: Here is a full example, given the confusion in the

Vectorization for meshgrid in Matlab (or Octave)

淺唱寂寞╮ 提交于 2019-11-27 08:04:01
问题 Vectorized code in Matlab runs much faster than a for loop (see Parallel computing in Octave on a single machine -- package and example for concrete results in Octave) With that said, is there a way to vectorize the code shown next in Matlab or Octave? x = -2:0.01:2; y = -2:0.01:2; [xx,yy] = meshgrid(x,y); z = sin(xx.^2-yy.^2); 回答1: As pointed out by @Jonas, there are a few options available in MATLAB, and which works best depends on a few factors such as: How large is your problem How many

Octave/Matlab: Adding new elements to a vector

假如想象 提交于 2019-11-27 07:02:25
Having a vector x and I have to add an element ( newElem ) . Is there any difference between - x(end+1) = newElem; and x = [x newElem]; ? ThijsW x(end+1) = newElem is a bit more robust. x = [x newElem] will only work if x is a row-vector, if it is a column vector x = [x; newElem] should be used. x(end+1) = newElem , however, works for both row- and column-vectors. In general though, growing vectors should be avoided. If you do this a lot, it might bring your code down to a crawl. Think about it: growing an array involves allocating new space, copying everything over, adding the new element,