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

In summary, the conversation is about using the fplot() function in Matlab with a 3-input argument function. The person asking for help is confused because fplot() only uses a function with one input variable, but the function they need to use has three input variables. They ultimately solve the problem by using the plot() function and providing a range of values for one input variable. They also mention a function they created called myfun3 that can be called with or without all three input variables.
  • #1
asdf12312
199
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
  • #2
Bump please..help me
 

1. How do I plot a 3-input argument function using fplot() in Matlab?

To plot a 3-input argument function using fplot() in Matlab, you can use the following syntax:
fplot(f,[xmin,xmax],'options')
Where 'f' is the function, [xmin,xmax] is the range of x values, and 'options' are additional formatting options such as color and line style.

2. What are the inputs for the fplot() function in Matlab?

The inputs for the fplot() function in Matlab are the function to be plotted, the range of x values, and any additional formatting options.

3. Can I plot multiple 3-input argument functions using fplot() in Matlab?

Yes, you can plot multiple 3-input argument functions using fplot() in Matlab by passing in a vector of functions as the first input. For example:
fplot([f1,f2,f3],[xmin,xmax],'options')

4. How do I change the color or line style of a 3-input argument function plot in Matlab?

You can change the color or line style of a 3-input argument function plot in Matlab by including the desired formatting options in the third input of the fplot() function. For example:
fplot(f,[xmin,xmax],'r--') would plot the function with a red dashed line.

5. Can I add a title or label to a 3-input argument function plot in Matlab?

Yes, you can add a title or label to a 3-input argument function plot in Matlab by using the title() and xlabel() functions respectively. These can be called after the fplot() function to add the desired title or label to the plot.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
5
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
806
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
954
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
879
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top