Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7088459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:48:13+00:00 2026-05-28T07:48:13+00:00

Say I have a function a = b / c and I ask the

  • 0

Say I have a function

a = b / c

and I ask the user to input two of these variables, either b and a or c and a and I want it to calculate the unknown variable without needing to write a function for every variable

In this case I would use:

pseudo-code
if input is a & b
then c = b / a
if input is a & c
then b = a * c
if input is b & c
then a = b / c

I know this is a function with only three variables so it is easy to put it in an if-statement and voilà BUT I want to apply it to a system containing lots of equations (a jet engine for example). I used TkSolver before and it was really great, you throw as many equations as you want at it (a jet engine was an example!), you only need to give a number of known quantities and in a few seconds, all the unknowns are calculated (even if I had a known quantity in one side of the equation and unknown on another side mixed with known ones, it will do the maths!)

So, is there a way to do this in MatLab or perhaps python which I’m learning?


Edit to the question, thanks for directing me to use the Symbolic toolbox, it’s great, I have another problem:

I couldn’t think of a way to let the program know which of the variables is entered. I can do this:

syms f a b c
f = a * c - b %(I want to write a = b / c)
c = 10; a = 5;
X = eval(solve(f,b))

What I want now is a way of letting the user enter two knowns (e.g c & a) and the code will recognise them and solve to the unknown variable (e.g b).


Edit 2: I managed to get what I want, it’s a bit long and there might be another way of achieving the same thing.

clear, clc
syms a b c
var = [{'a'}, {'b'}, {'c'}];
var1n = 0;
var2n = 0;

while isvarname(var1n) == 0
    var1n = input('Which variable is known: ','s');
    while ( any( strcmpi(var1n,var)  ) )== 0
        fprintf('\nThe variable entered is wrong, please enter a, b, or c')
        var1n = input('\nWhich variable is known: ', 's');
    end
end
fprintf('\nPlease enter the value of %s', var1n)
var1v = input(': ');
eval([var1n '=' num2str(var1v)]);

while isvarname(var2n) == 0
    var2n = input('What is the second known variable: ', 's');
    while ( any( strcmpi(var2n,var) ) ) == 0
        fprintf('\nThe variable entered is wrong, please enter a, b, or c')
        var2n = input('\nWhat is the second known variable: ', 's');
    end
end
fprintf('\nPlease enter the value of %s', var2n)
var2v = input(': ');
eval([var2n '=' num2str(var2v)]);


var3n = char (  var ( find( strcmpi(var1n, var) == strcmpi(var2n, var) ) )  );

var3v = solve(a - b / c);
eval([var3n '=' char(var3v)]);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:48:14+00:00Added an answer on May 28, 2026 at 7:48 am

    You could use this: http://www.mathworks.de/help/toolbox/symbolic/solve.html but you have to have the symbolic math toolbox (:

    EDIT: On the documentation page of solve there’s a sentence:

    If the right side of an equation is 0, specify the left side as a
    symbolic expression or a string:

    That means, if you want to solve a = b/c for the value which is NOT set, simply rewrite the equation so that there is a zero on the right hand side:, i.e. a - b/c = 0, than you can use:

    syms a b c
    % E.g. assign values to a and c and automatically let matlab chose the 'free' variable (in this case, it's b:
    a = input('Input var a: ')
    a = input('Input var c: ')
    solve(a - b/c)
    

    which than gives you b (e.g. entering a = 10 and c = 40 gives you b = a * c = 400). Input function is explained here: http://www.mathworks.de/help/techdoc/ref/input.html! Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure I know how to ask this. say I have a function
Say I have a function foo that I want to call n times. In
Lets say I have a function f[x_, y_] , and two lists l1 ,
Say I have a C function which takes a variable number of arguments: How
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
Say I have a function func(i) that creates an object for an integer i,
Say I have a function foo: (defun foo (x y &rest args) ...) And
Lets say I have a function where the parameter is passed by value instead
Let's say you have a function that returns a date: Date myFunc(paramA, paramB){ //conditionally
I'm sometimes confused to using which one of them, say I have a function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.