Intersection between two functions
Hi, fairly new to Matlab. Struggling with a question requiring me to find an x value for which:
2.2/sqrt(2*9.81*x) = tanh((3.5/(2*4.5))*sqrt(2*9.81*x)
Tried to use finding an intersection between two functions in accordance with another answer on this website, but I get multiple errors, both in graphing the function to see roughly where the correct solution should be and in finding a solution at all for the intersection. I also tried using symbolic variables (not sure what the difference is to be honest), but couldn’t get it to work.
I also get this error at the very start:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize
your function to return an output with the same size and shape as the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function/FunctionLine/updateFunction
In matlab.graphics.function/FunctionLine/set.Function_I
In matlab.graphics.function/FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 245)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 200)
In fplot>vectorizeFplot (line 200)
In fplot (line 166)
In question (line 7)
Error using /
Matrix dimensions must agree.
Error in question (line 15)
f1a= 2.2/(sqrt(2*9.81*x));
This is my code at the moment:
%input array
x=linspace(0,1,1000);
f1=@(x) 2.2/sqrt(2*9.81*x);
f2=@(x) tanh((3.5/(2*4.5))*sqrt(2*9.81*x));
% Graph functions
fplot(f1,’b’)
hold on
fplot(f2,’r’)
grid on
title(‘Finding Intersections of Functions’)
xlabel(‘Input Values (x)’)
ylabel(‘Ouput Values (f)’)
% Find the x-cordinates of intersecting points
f1a= 2.2/(sqrt(2*9.81*x));
f2a= tanh((3.5/(2*4.5))*sqrt(2*9.81*x));
Intersections=find(abs(f1a-f2a)<=(0.0001));
X_Values= x(Intersections)
Would appreciate any help.Hi, fairly new to Matlab. Struggling with a question requiring me to find an x value for which:
2.2/sqrt(2*9.81*x) = tanh((3.5/(2*4.5))*sqrt(2*9.81*x)
Tried to use finding an intersection between two functions in accordance with another answer on this website, but I get multiple errors, both in graphing the function to see roughly where the correct solution should be and in finding a solution at all for the intersection. I also tried using symbolic variables (not sure what the difference is to be honest), but couldn’t get it to work.
I also get this error at the very start:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize
your function to return an output with the same size and shape as the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function/FunctionLine/updateFunction
In matlab.graphics.function/FunctionLine/set.Function_I
In matlab.graphics.function/FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 245)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 200)
In fplot>vectorizeFplot (line 200)
In fplot (line 166)
In question (line 7)
Error using /
Matrix dimensions must agree.
Error in question (line 15)
f1a= 2.2/(sqrt(2*9.81*x));
This is my code at the moment:
%input array
x=linspace(0,1,1000);
f1=@(x) 2.2/sqrt(2*9.81*x);
f2=@(x) tanh((3.5/(2*4.5))*sqrt(2*9.81*x));
% Graph functions
fplot(f1,’b’)
hold on
fplot(f2,’r’)
grid on
title(‘Finding Intersections of Functions’)
xlabel(‘Input Values (x)’)
ylabel(‘Ouput Values (f)’)
% Find the x-cordinates of intersecting points
f1a= 2.2/(sqrt(2*9.81*x));
f2a= tanh((3.5/(2*4.5))*sqrt(2*9.81*x));
Intersections=find(abs(f1a-f2a)<=(0.0001));
X_Values= x(Intersections)
Would appreciate any help. Hi, fairly new to Matlab. Struggling with a question requiring me to find an x value for which:
2.2/sqrt(2*9.81*x) = tanh((3.5/(2*4.5))*sqrt(2*9.81*x)
Tried to use finding an intersection between two functions in accordance with another answer on this website, but I get multiple errors, both in graphing the function to see roughly where the correct solution should be and in finding a solution at all for the intersection. I also tried using symbolic variables (not sure what the difference is to be honest), but couldn’t get it to work.
I also get this error at the very start:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize
your function to return an output with the same size and shape as the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function/FunctionLine/updateFunction
In matlab.graphics.function/FunctionLine/set.Function_I
In matlab.graphics.function/FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 245)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 200)
In fplot>vectorizeFplot (line 200)
In fplot (line 166)
In question (line 7)
Error using /
Matrix dimensions must agree.
Error in question (line 15)
f1a= 2.2/(sqrt(2*9.81*x));
This is my code at the moment:
%input array
x=linspace(0,1,1000);
f1=@(x) 2.2/sqrt(2*9.81*x);
f2=@(x) tanh((3.5/(2*4.5))*sqrt(2*9.81*x));
% Graph functions
fplot(f1,’b’)
hold on
fplot(f2,’r’)
grid on
title(‘Finding Intersections of Functions’)
xlabel(‘Input Values (x)’)
ylabel(‘Ouput Values (f)’)
% Find the x-cordinates of intersecting points
f1a= 2.2/(sqrt(2*9.81*x));
f2a= tanh((3.5/(2*4.5))*sqrt(2*9.81*x));
Intersections=find(abs(f1a-f2a)<=(0.0001));
X_Values= x(Intersections)
Would appreciate any help. functions MATLAB Answers — New Questions