i'm trying to plot antenna radiation in scilab - scilab

formulla
imp=377;
c=3*10^8;
f=3*10^6;
i0=1;
teta=0:0.01:2*%pi;
lam=c/f;
l=lam/2;
k=2*%pi/lam;
r=10*lam;
ete=%iimpi0lexp(-kr)/(4%pi*r).*sin(teta);
polarplot(teta,ete);
at line 56 of function polarplot ( C:\Program Files\scilab-6.1.0\modules\graphics\macros\polarplot.sci line 69 )
min: Wrong type for input argument #1: A real matrix expected.
can anyone help me to fix this?

Vectors given to polarplot have to be real. Maybe you are missing a call to abs to compute the modulus of ete :
polarplot(teta,abs(ete))
S.

Related

is there fixed character that used in the exponential function?

I want to solve this problem using the sympy.
[a copper ball heated to 100 degrees was placed in water at 30 degrees, and after 3 minute, the temperature of the copper ball dropped to 70 degrees. Find the time it takes for the temperature of the copper ball to drop to 31 degrees. According to the experiment, the temperature change rate of the copper ball is proportional to the difference between the temperature and the ambient temperature.]
So, I built this equation and conditions.
[T : the temperature of the ball // t : time [m] // a : proportional constant]
[dT/dt = -a(T-30), T(0)=100, T(3)=70]
And my code is as follows...
T = symbols('T', cls=Function)
t = symbols('t')
a = symbols('a')
deqn = Eq(T(t).diff(t), -a*(T(t)-30))
dsolve(deqn) # general solution
The general solution of the above is : 𝑇(𝑡)=𝐶1𝑒−𝑎𝑡+30
dsolve(deqn, ics={T(0):100}) #particular solution by boundary condition
And the particular solution is : 𝑇(𝑡)=30+70𝑒−𝑎𝑡
Now, I think I need to using this equation to find the value of 'a' due to T(3)=70.
C = Eq(30+70*exp(-a*t),30)
solve(C)
But, the error occurs...
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [122], in <cell line: 1>()
----> 1 C = Eq(30+70*exp(-a*t),30)
2 solve(C)
TypeError: bad operand type for unary -: 'list'
I don't know what the problem is...
is there a set character when using 'exp'?
please..help...me....
You might have an old version of sympy that used to return symbols in a list. Check type(a) is list. If it is True, then use a newer version of SymPy, or use Symbol to create a single symbol, or unpack the list a = symbols('a')[0].
If that is not the issue, make sure to put 31 as the 2nd arg for C (per problem description, else the Eq will be False). And then use solve(C, t) or else it might try solve for a.

InterpND for one dimension

I'm trying to use the function InterpND from openmdao.components.interp_util.interp.
No problem using it for multidimensional data - I can interpolate a 3-D tensor without problems. However I'd also like to use for 1-D data. Not sure what I am doing wrong, but when I try to do something really simple like
import numpy as np
from openmdao.components.interp_util.interp import InterpND
x = np.array([0.,1.,2.,3.,4.])
y = x**2
f = InterpND(points=x, values=y)
I get the following error message:
ValueError: There are 5 point arrays, but values has 1 dimensions
Looking at the InterpND source code it seems like I SHOULD be able to just have x and y as simple 1-D arrays.
Parameters
----------
points : ndarray or tuple of ndarray of float, with shapes (m1, ), ..., (mn, )
The points defining the regular grid in n dimensions. For 1D interpolation, this
can be an ndarray.
values : array_like, shape (m1, ..., mn, ...)
x is a 1D ndarray, y is also a 1D nd array.
This looks like a bug in OpenMDAO V3.7.0 related to the input error checking. Here is a workaround. If you put the 1-D table points into a list, it works without error:
f = InterpND(points=[x], values=y)

SCILAB undefined vairable error when using 'polarplot'

I am getting the following error while running polarplot in scilab
// Program to plot using polarplot function
t= 0:.01:2*%pi;
polarplot(sin(t))
xtitle('Using polarplot'
result:
exec('D:\mangesh\SCILAB PROJ\sample\polarplot.sce', -1)
at line 13 of function polarplot ( C:\PROGRA~1\SCILAB~1.1\modules\graphics\macros\polarplot.sci line 25 )
at line 3 of executed file D:\mangesh\SCILAB PROJ\sample\polarplot.sce
Undefined variable: rho
The polarplot function requires at least 2 input arguments theta and rho,
In your example you forgot to give the evolution of the radius. for example:
polarplot(sin(t), ones(t))
As indicated by the other user as well the polarplot function requires at least two input vectors, like most of other plotting functions. It this case you probably want something like:
// Program to plot using polarplot function
t = 0:.01:2*%pi;
polarplot(t, sin(t));
xtitle('Using polarplot');
which yields:

Plotting a function in scilab

can you help me, I 'm trying to plot the function y=1/x in scilab,
the graph that throws me is incorrect
x = [1:1:10]';
y = 1./x;
plot(x,y)
and throws me these results
y=
0.0025974
0.0051948
0.0077922
0.0103896
0.0129870
0.0155844
0.0181818
0.0207792
0.0233766
0.0259740
and this result is wrong , as would be the code ,
Thanks for the help :)
Write
y = 1 ./ x;
instead of
y = 1./x;
From the documentation (emphasis is mine):
a ./ b is the matrix with entries a(i,j)/ b(i,j). If b is scalar (1x1 matrix) this operation is the same as a./b*ones(a). (Same convention if a is a scalar).
Remark that 123./b is interpreted as (123.)/b. In this cases dot is part of the number not of the operator.

Can't generate a surface plot in scilab

I'm having trouble generating a three-dimensional surface plot in Scilab. I keep getting the error:
!--error 999
Objplot3d: x vector is not monotonous.
I'm using the command:
plot3d(x,y,z)
where x and y are 200X1 matrices (aka column vectors) and z is a 200X200 matrix. I thought maybe I had to transpose y, but that led to the same error as well.
help plot3d requires, indeed, that the first two arguments be monotonous (ie sorted). I wish someone could tell me why!
Since your x (and possibly y) is not ordered, which causes the error, you just need to sort them, and then pay some attention to keep the z values where they belong. Something like:
[newx,ix]=gsort(x);
[newy,iy]=gsort(y);
newz = z(ix,iy);
plot3d(newx,newy,newz)
(ix is the permutation such that x(ix)==newx)

Resources