help-octave
[Top][All Lists]
Advanced

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

Re: Plotting problem after for-endfor roop


From: marco atzeri
Subject: Re: Plotting problem after for-endfor roop
Date: Thu, 15 Mar 2012 17:43:47 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 3/15/2012 8:11 AM, okayasu wrote:
I've just started to learn octave.
The following code calculates a resistive-wall impedance
that depends on a accelerator resonance frequency.

Calculation results; frequencies and impedances are properly written
in a file named "test.dat".
However, plotting results seem to represent last few lines or one line.
Could anybody suggest me that how to solve this issue ?

Thanks,
Okayasu

### octave macro (named test.m) from here ###
#General constants
c=2.99E+8;
ep0=8.85E-12;
#Conditions
#b: Bore radius
#d: duct thickness
b=8.0E-3;
d=2.0E-3;
#SUS316L
sigma=1.4E+6;
mu0=1.25E-6;

fid=fopen("test.dat","w");
for j=0:0.1:15
omega=10^j;
delta=sqrt(2/sigma/mu0/omega);
lam=(i+sign(omega))/delta;
c1=real(lam*b);
c2=real(lam*(b+d));
alp1=(besselj(1,c1)*bessely(0,c2)-bessely(1,c1)*besselj(0,c2))/(besselj(0,c1)*bessely(0,c2)-bessely(0,c1)*besselj(0,c2));

z_pal=-i/(2*pi*ep0*b*c*((omega/lam/c+lam*c/omega)*alp1-b*omega/2/c));

fprintf(fid,"%8.6e %8.6e %8.6e %8.6e\n",omega,delta,imag(z_pal),abs(z_pal));
endfor
fclose(fid);
loglog(omega,abs(z_pal));
### octave macro (named test.m) to here ###


in general test.m is not a good idea, as there is already a file called in that way.
/usr/share/octave/3.6.1/m/testfun/test.m

in your case the plot is performed only on the last couple of points

octave:3> omega
omega =  1.0000e+15
octave:4> abs(z_pal)
ans =  0.56203

try in this way:

-----------------------------------
### octave macro (named test.m) from here ###
#General constants
c=2.99E+8;
ep0=8.85E-12;
#Conditions
#b: Bore radius
#d: duct thickness
b=8.0E-3;
d=2.0E-3;
#SUS316L
sigma=1.4E+6;
mu0=1.25E-6;

hold on

for j=0:0.1:15
omega=10^j;
delta=sqrt(2/sigma/mu0/omega);
lam=(i+sign(omega))/delta;
c1=real(lam*b);
c2=real(lam*(b+d));
alp1=(besselj(1,c1)*bessely(0,c2)-bessely(1,c1)*besselj(0,c2))/(besselj(0,c1)*bessely(0,c2)-bessely(0,c1)*besselj(0,c2));

z_pal=-i/(2*pi*ep0*b*c*((omega/lam/c+lam*c/omega)*alp1-b*omega/2/c));

fprintf(fid,"%8.6e %8.6e %8.6e %8.6e\n",omega,delta,imag(z_pal),abs(z_pal));
loglog(omega,abs(z_pal),"x");
endfor
fclose(fid);
--------------------------------------------------------





reply via email to

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