- #1
krnhseya
- 103
- 0
I think I posted in a wrong forum...I wasn't sure which category I was supposed to post this under but here it goes...
1. Homework Statement
Find x where r varies from 0 to 4.
2. Homework Equations
x-(r/4)*sin(pi*x)=0
3. The Attempt at a Solution
The problem that I ran into with MATLAB is that when I create a sub-m file for fsolve, it requires 2 equations whereas I only have 1 equation.
function F=myfun(x,r)
F(1)=x-(r/4)*sin(pi*x);
My executable is:
var_new=[];
for r=0:0.01:4;
var=fsolve(@myfun,0.5)
var_new=[var_new var]
i=i+1;
end
I expect to get "var" variable to be a single number where my "relevant equation" is set to zero. var_new is simply creating an array for me to plot r versus var.
Thank you.
1. Homework Statement
Find x where r varies from 0 to 4.
2. Homework Equations
x-(r/4)*sin(pi*x)=0
3. The Attempt at a Solution
The problem that I ran into with MATLAB is that when I create a sub-m file for fsolve, it requires 2 equations whereas I only have 1 equation.
function F=myfun(x,r)
F(1)=x-(r/4)*sin(pi*x);
My executable is:
var_new=[];
for r=0:0.01:4;
var=fsolve(@myfun,0.5)
var_new=[var_new var]
i=i+1;
end
I expect to get "var" variable to be a single number where my "relevant equation" is set to zero. var_new is simply creating an array for me to plot r versus var.
Thank you.