2D plot of a function WITH MATLAB

  • MATLAB
  • Thread starter aredy29
  • Start date
  • #1
10
0

Main Question or Discussion Point

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.
 

Answers and Replies

  • #3
10
0
still not clear..
 
  • #4
11,366
4,837
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
 
  • #5
10
0
how should I define my function ? I keep getting 'm power error'
 
  • #6
11,366
4,837
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.
 
  • #7
11,366
4,837
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
 

Related Threads for: 2D plot of a function WITH MATLAB

Replies
3
Views
13K
Replies
1
Views
17K
  • Last Post
Replies
2
Views
33K
Replies
0
Views
5K
Replies
4
Views
6K
Replies
3
Views
4K
Replies
3
Views
1K
Top