1
votes

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 :)

1

1 Answers

0
votes

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.