octave

How to pretty print a matrix in Octave?

三世轮回 提交于 2019-12-24 06:38:10
问题 I want to create a pretty printed table from a matrix (or column vector). For Matlab there are several available functions that can do this (such as printmat, array2table , and table ), but for Octave I cannot find any. So instead of: >> a = rand(3,2)*10; >> round(a) ans = 2 10 1 3 2 1 I would like to see: >> a = rand(3,2)*10; >> pretty_print(round(a)) THIS THAT R1 2 10 R2 1 3 R3 2 1 How can I produce a pretty printed table from a matrix? (Any available package to do so?) UPDATE After trying

Using R to write a .mat file not giving the right output?

回眸只為那壹抹淺笑 提交于 2019-12-24 04:30:17
问题 I had a .csv file that I wanted to read into Octave (originally tried to use csvread). It was taking too long, so I tried to use R to workaround: How to read large matrix from a csv efficiently in Octave This is what I did in R: forest_test=read.csv('forest_test.csv') library(R.matlab) writeMat("forest_test.mat", forest_test_data=forest_test) and then I went back to Octave and did this: forest_test = load('forest_test.mat') This is not giving me a matrix, but a struct. What am I doing wrong?

Model measurement and error in NumPy

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 03:05:55
问题 I'd like to try the SciPy suite instead of Octave for doing the statistics in my lab experiments. Most of my questions were answered here, there is just another thing left: I usually have an error attached to the measurements, in Octave I just did the following: R.val = 10; R.err = 0.1; U.val = 4; U.err = 0.1; And then I would calculate I with it like so: I.val = U.val / R.val; I.err = sqrt( (1 / R.val * U.err)^2 + (U.val / R.val^2 * R.err)^2 ); When I had a bunch of measurements, I usually

matlab/octave random event ode45

一笑奈何 提交于 2019-12-24 02:08:11
问题 I have some troubles in understanding how to implement events in octave/matlab, in the resolution of differential equations. Consider for example this simple code to solve the differential equation y' = -y: function dy = odefun(t,y) dy = -y; endfunction options = odeset('RelTol',1e-4,'AbsTol',[1e-4]); [T,Y] = ode45(@odefun,[0 12],[1],options); Now I would like to introduce a random event. For example at some fixed time step I would like to randomly change the value of y and then continue the

How to know rotation degree in matlab for a rotated image?

我们两清 提交于 2019-12-24 01:25:09
问题 I would like to : step 1) Rotate an image with 20 degrees using this code rotatedImage = imrotate(originalImage, 20); . step 2) calculate degree rotation used in step 1 based only on the rotated image if it possible or based on rotated image and the original image. there is any function in matlab could do the step 2 or a proposition to do that? 回答1: This example shows one way to perform step 2: A = 'peppers.jpg'; img = im2double(imread(A)); img_r=imrotate(img,20,'nearest','crop'); % <-- this

Reading out specific points off the Matlab / Octave fft2() function output

不问归期 提交于 2019-12-24 00:38:44
问题 I am getting familiarized with Octave and the function fft2() . In this toy example, I am aiming at producing the 2D DFT of the following 256 x 256 png image: To be able to understand the output easily, I try to convert this image into a 256 x 256 image, eliminating color information: Im = imread('circ.png'); pkg load image Im = rgb2gray(Im); figure, imshow(Im) After this bookkeeping preliminaries I run: A = fft2(double(Im)); OK. Now I take the same image, and analyze it with ImageJ, checking

Transpose of a row vector in Octave causing problems with string escape character

試著忘記壹切 提交于 2019-12-23 19:22:39
问题 In Sublime, I'm trying to take the transpose of a row vector in an Octave file as such: y = [4, 5, 6]; y_transpose = y'; But whenever I try to run this in Octave, it acts as if introduction of the transpose operator (the ') is the beginning of a string, and ignores the following lines of code. How can I remedy this? 回答1: I don't know why it isn't working. ' is actually listed as an operator in the docs. But as a workaround, you could use the transpose function. y = [4, 5, 6]; y_transpose =

Custom axis scales - “Reverse” logarithmic?

隐身守侯 提交于 2019-12-23 09:58:56
问题 Sorry about the poor title ;) I'm trying to recreate a matlab plot I've come across in some other work, but I don't quite understand the scale they are using. The y axis increments are as follows (from the top [+ve y]): 0.9999, 0.999, 0.99, 0.9, 0 I can use semilogy to plot a logarithmic graph, but this is kind of the wrong way round; my increments go 1, 0.1, 0.01, 0.001, etc which is actually 1 - i , where i is the increments I actually want! I don't entirely understand how to describe this

Octave basics: How to assign variables from a vector

久未见 提交于 2019-12-23 09:31:11
问题 Maybe I'm spoiled by Python, but does Octave allows one to assign the values of variables directly from a vector? That is, doing something like a,b,c=[5,6,7] will result with a=5, b=6, c=7 . I have tried many combinations of writing the expression above, but no luck yet ... 回答1: This can be done by constructing a cell array with "{...}" and converting this to a comma separated list via "{:}": [a b c] = {5 6 7}{:} a = 5 b = 6 c = 7 来源: https://stackoverflow.com/questions/9908398/octave-basics

How to check if a variable is defined in Octave?

て烟熏妆下的殇ゞ 提交于 2019-12-23 08:56:52
问题 When writing a script that loads data, it's a waste of time to wait for it to load each time. How to check to see if the variable is defined? 回答1: You can use the exist function in Octave to do the work. It can be used to check the existence of given name as a variable, built in function, file, or directory. In you case, to check the existence of a variable, you may use something like this: if (exist("your_var_name", "var") == 1) printf("varname exists"); else printf("varname not exists");