# Help in creating function , built in equation

1 view (last 30 days)
Ali Tawfik on 23 Aug 2019
Commented: Walter Roberson on 24 Aug 2019
Hi All,
I am trying to build in function, including equation which is a result of another code,
I understand function is a separate script but I just need to do something smart, no to add the equation in every time ,
below is the code:
clear all;
clc;
syms x y;
an=solve(-15== 10*x+2*y,y);
ap=solve(10*x+2*y ==20,y);
yin=[an,ap]
damontwo % Name of the function
%% function
function damontwo(x)
yin(:,1)=input('Enter equation to solve ')
end
When I type an: I got an error ?, however, when I type equation, it works, so could anyone please help me, how could I introduce that to the function ?
Thanks,

Walter Roberson on 23 Aug 2019
syms x y;
eqns = damontwo(x,y);
solve(eqns)
%% function
function yin = damontwo(x,y)
yin(1) = input('Enter first equation to solve ');
yin(2) = input('Enter second equation to solve ');
end

Walter Roberson on 24 Aug 2019
I do not understand what you need. What does it mean to type it as a variable but not as an equation? Have have something as a result of a previous equation? Okay, what form is that in? Is a symbolic expression? Is it a character vector?
Ali Tawfik on 24 Aug 2019
Thanks Walter, I mean yin(:,1)=an
(an) is a result of a previous equation
clear all;
clc;
syms x y;
an=solve(-15== 10*x+2*y,y);
ap=solve(10*x+2*y ==20,y);
yin=[an,ap]
damontwo % Name of the function
%% function
function damontwo(x)