Hello!
I've just installed octave (cygwin) to my computer and now learning the
difference between octave and matlab.
I can find the solution for the followings on my own. Please help me and sorry
for the supposingly stupid questions.
1. dir command does not work:
octave:15> dir
usage: dir (file)
error: evaluating if command near line 53, column 3
error: called from `dir' in file
`/usr/share/octave/2.1.71/m/miscellaneous/dir.m'
??? What can be wrong?
2. In one of my mfiles the plot command does not work. Why?
I copied the short m file to the end of this mail. The graphs are not showed, no error reports, no any messages at all but plot command works pretty well in another mfile with the same syntax. So I really have no any idea what could happen. All things that happen is something like that:
octave:19> mine
MINE MANAGEMENT MODEL
octave:20>
thanks in advance
Klári
===============================mine.m=======================================
% Mine Management Model
fprintf('\nMINE MANAGEMENT MODEL\n')
% close all
% Enter algorithm parameters
maxit = 100;
tol = sqrt(eps);
% Enter model parameters
price = 1; % price of ore
sbar = 10; % initial ore stock
delta = 0.9; % discount factor
% Construct state and action spaces
S = (0:sbar)'; % vector of states
X = (0:sbar)'; % vector of actions
n = length(S); % number of states
m = length(X); % number of actions
% Construct reward function (f) and state transition function (g)
% Vectorized version
[SS,XX] = gridmake(S,X);
f = (price-XX./(1+SS)).*XX;
f(XX>SS) = -inf;
f = reshape(f,n,m);
g = getindex(SS-XX,SS);
g = reshape(g,n,m);
clear SS XX
P = sparse(1:n*m,g(:),1,n*m,n);
% policy iteration
v = zeros(n, 1);
for it=1:maxit
vold = v;
[v, x] = valmax(v, f, P, delta);
if norm(v-vold)< tol
return;
end
end
% Plot optimal value function
figure(1);
plot(S,v,';;',)
title('Optimal Value Function');
xlabel('Stock'); ylabel('Value');
% Plot optimal policy function
figure(2);
plot(S,X(x))
title('Optimal Extraction Policy');
xlabel('Stock'); ylabel('Extraction');
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------