octave

How to open .m files in octave on OSX 10.6.8

℡╲_俬逩灬. 提交于 2019-12-13 19:57:51
问题 This file ex1.m, I "open with" octave, but it doesn't do anything. the first few lines of code are.... %% Machine Learning Online Class - Exercise 1: Linear Regression % Instructions % ------------ % % This file contains code that helps you get started on the % linear exercise. You will need to complete the following functions % in this exericse: % % warmUpExercise.m % plotData.m % gradientDescent.m % computeCost.m % gradientDescentMulti.m % computeCostMulti.m % featureNormalize.m % normalEqn

Implementation of Matlab's uicontrol in Octave?

徘徊边缘 提交于 2019-12-13 12:38:51
问题 I am trying to run the .m Matlab code of a graphics program used in our lab in Octave. Octave tells me there is no definition of the function "uicontrol", which is used in the code. After some searching, I read that the package JHandles has an implementation of the "uicontrol" GUI function. However, I can't find jhandles anywhere. Therefore: Can someone tell me how to get the jhandles package and get it running in my copy of Octave, installed in Mac OS X 10.6? OR Is there another

What does this syntax [0:1:5] mean (do) in the context of the given code?

孤街醉人 提交于 2019-12-13 09:14:47
问题 I don't understand how [0:1:5] is being used in the code below: function [x , y] = plotTrajectory(Vo,O,t,g) % calculating x and y values x = Vo * cos(O) * t ; y = Vo*(sin(O)*t)-(0.5*g*(t.^2)); plot (x,y); hold on end for i = (0: (pi/8): pi); [x,y] = plotTrajectory(10,i,[0:1:5],9.8); end 回答1: Each of the parameters are being used to find particular X and Y values. O changes from 0 to pi in steps of pi/8 while Vo , t and g remain unchanged. The t variable is simply an array from 0 to 5 in steps

how to find intersection points when lines are created from an array [duplicate]

五迷三道 提交于 2019-12-13 08:51:39
问题 This question already has answers here : Finding where plots may cross with octave / matlab (2 answers) Closed 5 years ago . The intersections functioned recommended below worked great for arrays up to 8000 values but if I had an array of 100000 values or more I would run out of memory, (and I have 16gig of ram) this most likely was caused due to the repmat command with the intersections function. I'm trying to find the intersection points of lines created from an array. but keep getting an

Change dtype data_type fields of numpy array

六眼飞鱼酱① 提交于 2019-12-13 07:18:46
问题 I have a .mat file which I load using scipy : from oct2py import octave import scipy.io as spio matPath = "path/to/file.mat" matFile = spio.loadmat(matPath) I get a numpy array which I want to pass to octave function using oct2py , like that: aMatStruct = matFile["aMatStruct"] result = octave.aMatFunction(aMatStruct) But I get the following error: oct2py.utils.Oct2PyError: Datatype not supported It seems it's due to the array dtype , which looks like: [('x', 'O'), ('y', 'O'), ('z', 'O')] So I

Is it possible to open a ljpg (lossless jpeg) file in Python?

纵然是瞬间 提交于 2019-12-13 06:44:32
问题 Does anyone know if it is possible to open a ljpg (lossless jpeg) file in Python? (specifically I'm using spyder on Windows XP). I've searched around on Google, here and the Python documentation and I can't see anything. If it's not possible, I'll try to work out how to call Octave to convert it, but it would be great if I didn't have to do that. Thanks! 回答1: Since the below didn't work, try this wrapper: http://ebiznisz.hu/python-jpegtran/ Appears to do the trick. http://www.pyglet.org/doc

Octave: How can I vectorize this function?

爱⌒轻易说出口 提交于 2019-12-13 04:00:00
问题 Can these for-loops of this function be vectorized? function [sta]=bootstrap(data,N,p) rand('state', sum(100*clock)); n=length(data); n1=round(prctile(1:n,(100-p)/2)); n2=round(prctile(1:n,p/2+50)); for i=1:N choose=round(((n-1)*rand(1,n))+1); for j=n1:n2 sample(j-n1+1,1)=data(choose(j)); end sta(i)=mean(sample); end 回答1: Yes you can, try to replace your loop with the code below: choose=round(((n-1)*rand(N,n))+1); sample(:,(n1:n2)-n1+1,1)=data(choose(:,n1:n2)); sta=mean(sample'); The point is

Octave -inf and NaN

穿精又带淫゛_ 提交于 2019-12-13 01:44:40
问题 I searched the forum and found this thread, but it does not cover my question Two ways around -inf From a Machine Learning class, week 3, I am getting -inf when using log(0) , which later turns into an NaN . The NaN results in no answer being given in a sum formula, so no scalar for J (a cost function which is the result of matrix math). Here is a test of my function >> sigmoid([-100;0;100]) ans = 3.7201e-44 5.0000e-01 1.0000e+00 This is as expected. but the hypothesis requires ans = 1

Convert Color image to grayscale image using Octave

梦想与她 提交于 2019-12-12 22:22:57
问题 I have a color image that I'm trying to convert to grayscale, but I get an error: warning: the 'rgb2gray' function belongs to the image package from Octave Forge but has not yet been implemented I'm using Octave 4.2.2 on Ubuntu 18.04 64-bit and can't upgrade this version to Octave 5.1 yet. Is there a workaround? My goal is: To convert a color image into grayscale. Then place the intensity/brightness of each grayscale pixel into a range between 0-1 . My code: pkg load image % read image from

Can someone explain the behavior of the functions mkpp and ppval?

此生再无相见时 提交于 2019-12-12 17:08:39
问题 If I do the following in MATLAB: ppval(mkpp(1:2, [1 0 0 0]),1.5) ans = 0.12500 This should construct a polynomial f(x) = x^3 and evaluate it at x = 1.5 . So why does it give me the result 1.5^3 = .125 ? Now, if I change the domain defined in the first argument to mkpp , I get this: > ppval(mkpp([1 1.5 2], [[1 0 0 0]; [1 0 0 0]]), 1.5) ans = 0 So without changing the function, I change the answer. Awesome. Can anyone explain what's going on here? How does changing the first argument to mkpp