Matlab help fplot() with 3-input argument function?

Click For Summary
The discussion revolves around using the MATLAB function fplot() with a function that requires three input arguments, which fplot does not support since it only accepts one input variable. The user initially faced challenges but ultimately resolved the issue by using the plot() function instead. They clarified that with two input variables set as constants, only one variable (x) varies, allowing for a range of values to be plotted. The provided MATLAB code demonstrates how to define the function and generate the plot. The user seeks confirmation on the correctness of their approach and the resulting graph.
asdf12312
Messages
198
Reaction score
1
matlab halp! fplot() with 3-input argument function??

Homework Statement


heres da link: http://postimg.org/image/uqqr3q0k3/

don't really need to look at that though. Its just a function in another file, I have to call it but it takes 3 input variables, problem with fplot is it only uses a function with one input variable (i.e. x).. and i (think??) that the function has to plot the values that is the output to the equation. so inside it after it calculates it would plot the points so I would probably the plot would already be given when I call the function..?? For the hint 'fplot' was given so I was confused. I actually solved it without use of fplot (plot instead) but here is the basic:

with 2 input variables are constant, so only one is varying (x). which is range of numbers with step size. so here is my MATLAB code which i will post ni next section. also i could have done it another way, set an output for the function that would be the range of values. but there is no output at all except the plot graph, since the ? didnt ask about it.

Homework Equations



Code:
function [] = myfun3( x, m, s)
if nargin==1
    m=2.5;
    s=0.8;
end

out=(1/(s*sqrt(2*pi)))*exp(0.5*((x-m)/s).^2);
plot(out);title(['g(x) for values x=',num2str(min(x)),' to x=',num2str(max(x)), ' with step=',num2str(x(max(x))-x(max(x)-1)),', m=',num2str(m),', s=', num2str(s)]);
end

to call it i type:
myfun3(0:0.05:5,2.5,0.8) or myfun3(0:0.05:5)

The plot I got for this I have below, think this is right:
http://postimg.org/image/o50e9d0tr/
 
Last edited:
Physics news on Phys.org
Bump please..help me
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K