How can I perform a recursive input using the solve function?
Show older comments
I've created some code to simulate a crank-rocker mechanism and I'm wondering how to perform an operation where I take the crank rotating 360 degrees and spit out all of the theta values for each corresponding link of the mechanism.
For reference: r1 = ground, r2 = crank, r3 = attachment link, r4 = rocker
t1, t2, t3, t4 are all thetas for reach respective link
Here is the code:
r1=4.2; r2=1; r3=5; r4=2.032;
t1=0; t2=0:1:360;
syms t3 t4 positive
eqn1 = r2.*cosd(t2)+r3.*cosd(t3)==r1.*cosd(t1)+r4.*cosd(t4);
eqn2 = r2.*sind(t2)+r3.*sind(t3)==r1.*sind(t1)+r4.*sind(t4);
S = solve(eqn1, eqn2, 'IgnoreAnalyticConstraints', true)
When I run the code, it gives me 4 error messages:
Second argument must be a vector of symbolic variables.
checkVariables(vars)
[eqns, vars] = sym.getEqnsVars(argv{:});
[eqns,vars,options] = getEqns(varargin{:});
I'm just looking to find a way to scale t2 from 0 to 360 degrees such that t3 and t4 give positive values only. I know how to do this with a single number, but once t2 becomes an array, I don't know how to solve those issues.
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics 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!