saving real roots in a vector; "solve" gives me weird results
Show older comments
Hi - I want to save in a vector the coordinates of the points in which one function reaches a certain level.
For reference, let's consider the following function and graph:
clear all; close all; clc;
GAMMA =1.1;
AHIGH=1;
ALOW=0.4;
CC= 0.0283;
LEVEL = 26.5155;
PRAM = 70.7090;
% PLOT GRAPH
f = @(x,y) ALOW*x*GAMMA*PRAM/sqrt(x^2 +1)-ALOW*(x-CC)/AHIGH-CC-y;
fimplicit(f,[-2 100 -50 50])
hold on
xplot1 = -2:0.01:100;
lineplot33= LEVEL*ones(1, length(xplot1));
plot(xplot1, lineplot33)
hold off
One can see from the graph that the function f reaches the level LEVEL = 26.5155 in two points; by eye-balling them, their coordinates on the X axis should be around 3 and 13, respectively.
I want to save those 2 values in a vector. I'm trying to do that using "solve" but I get weird results. (I'm not very proficient with the Symbolic toolbox I'm afraid).
What's a better way to do that? Here's my current (wrong) code:
% I WANT TO SAVE THE "ROOTS" IN A VECTOR
syms x real
eqn2=LEVEL==ALOW*x*GAMMA*PRAM/sqrt(x^2 +1)-ALOW*(x-CC)/AHIGH-CC;
[SOLVE21, prams, cnds]= solve(eqn2,x,'ReturnConditions',true)
Accepted Answer
More Answers (0)
Categories
Find more on Nearest Neighbors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!