can i define a function cv = f(t1, t2) and solve for one of its inputs with something like "solve(100 == cv, t1)" in matlab

You can define the function cv with inputs t1 and t2 in MATLAB like this:

main.m
function cv = f(t1, t2)
    % your code here
end
49 chars
4 lines

Then, to solve for t1 when cv is equal to 100, you can use the solve function like this:

main.m
syms t1
t2 = 2; % set t2 to some value
cv = f(t1, t2);
eqn = cv == 100;
sol_t1 = solve(eqn, t1);
97 chars
6 lines

This creates a symbolic variable t1, sets t2 to a value of 2, evaluates cv using f(t1, t2), creates an equation eqn to solve (cv == 100), and then solves for t1 using solve(eqn, t1). The output sol_t1 is a symbolic expression for t1 that makes cv equal to 100.

Note that the solve function only works with symbolic equations, so you need to use the syms command to create symbolic variables. Also, if your function f is not already defined, you will need to fill in the "your code here" section with the actual formula for cv.

gistlibby LogSnag