2D plot of a function WITH MATLAB

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
6 replies · 5K views
aredy29
Messages
10
Reaction score
0
My function is;

y(x,s)= 1-(cos[(s-1)arctan(x)]*gamma(s-1))/(1+x^2)^(s-1)/2

varible x will have range from 0 to 10. At one time the s value will be constant e.g. s = 3 but I want to change s for different values( is there any commands in MATLAB that will allow me to do this ?). I tried many time but can't get it.
 
Physics news on Phys.org
The idea is to construct a loop to generate the s values say from 0 to 5:

for s = 1:5
x=0:10
y=s*x.*x
plot(x,y)
hold all
end
 
how should I define my function ? I keep getting 'm power error'
 
Here's an example I did in Freemat, a MATLAB clone, as I don't use MATLAB much anymore

for i = 1:5
s=i
x=0:10
y=s*x
plot(x,y)
hold('on')
end

It draws five plots on one chart with varying s values.
 
for your eqn arctan should be atan and for x^s powers you could use power(x,s)

alternatively x^2 = x.*x dots x to x to get a vector of x^2 values