help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

m-file questioin


From: A. Scott Hodel
Subject: m-file questioin
Date: Wed, 13 Oct 93 09:00:05 CDT

The m-file below runs fine under octave-0.74, but gives errors under
octave-0.76.

----------------------------------------  0.74 ----------------------
/home/hodelas/mfiles/pat $ octave
Octave, version 0.74.  Copyright (C) 1992, 1993, John W. Eaton.
This is free software with ABSOLUTELY NO WARRANTY.
For details, type `warranty'.

octave:1> freq
Frequency response example
gpoles =

   -1.00000 - 1.00000i   -1.00000 + 1.00000i   -0.75000 + 0.00000i

npoles = 3
gzeros =

   0.50000 - 0.50000i   0.50000 + 0.50000i

nzeros = 2
Frequency response range:
Enter minimum frequency of plot (rad/s):1
fr_min = 1
Enter maximum frequency of plot (rad/s):100
fr_max = 100
Enter number of points in frequency plot:100
fr_npts = 100
press a key to continue
octave:2>  
octave:2> quit

----------------------------0.76 --------------------------------
/home/hodelas/mfiles/pat $ octave-0.76
Octave, version 0.76.  Copyright (C) 1992, 1993, John W. Eaton.
This is free software with ABSOLUTELY NO WARRANTY.
For details, type `warranty'.

octave:1> freq
Frequency response example
gpoles =

   -1.00000 - 1.00000i   -1.00000 + 1.00000i   -0.75000 + 0.00000i

npoles = 3
gzeros =

   0.50000 - 0.50000i   0.50000 + 0.50000i

nzeros = 2
Frequency response range:
Enter minimum frequency of plot (rad/s):1
fr_min = 1
Enter maximum frequency of plot (rad/s):100
fr_max = 100
Enter number of points in frequency plot:100
warning: implicit conversion of complex value to real value
error: invalid  index = 0
error: evaluating assignment expression near line 18, column 8
fr_npts = 100
octave:2> quit
--------------------- (same results on a Sparc-station as on Dells) ----
------------------------ freq.m --------------
disp('Frequency response example')
gpoles = [ -1-i, -1+i, -0.75]
npoles = length(gpoles)
gzeros = [ (1-i)/2, (1+i)/2]
nzeros = length(gzeros)

disp('Frequency response range:')
fr_min = input('Enter minimum frequency of plot (rad/s):')
fr_max = input('Enter maximum frequency of plot (rad/s):')
fr_npts = input('Enter number of points in frequency plot:')
om = i*logspace(log10(fr_min),log10(fr_max),fr_npts);

for i=1:length(om)

 gs(i) = 1;
 for j=1:nzeros
   gs(i) = gs(i)*(om(i) - gzeros(j));
 endfor

 for j=1:npoles
   gs(i) = gs(i)/(om(i) - gpoles(j));
 endfor

endfor

% output the bode plots
loglog(imag(om),abs(gs))
xlabel('Omega')
ylabel('magnitude - open loop')
title('Magnitude bode plot')
disp('press a key to continue')
pause

semilogx(imag(om),angle(gs))
xlabel('Omega')
ylabel('phase - open loop')
title('phase bode plot')


reply via email to

[Prev in Thread] Current Thread [Next in Thread]