

You would then have to generate 28 functions and select the approriate ones based on the given input variables. You could of course build upon that solution and create a symbolic system of equations which incorporates all your 8 variables. Result = dot(eval(sol_func), eval(cond_func)) Įxample run: > calc_third('gamma', 0.5, 'TR', 100) I have written a hacky solution which only accounts for the case:Ģ out of the 3 variables )

Also, I realised that since Matlab will read from top to bottom, is there any way to account for this?Īs we already wrote in the comments, what you try to do is very complicated and rather infeasible without the symbolic toolbox.

This would further be carried into subsequent equations, where I would get "M2","PR","rhoR","P0R" and "P1R". The program will be able to do like, let's say the user enter "TR" and "gamma", and then Matlab will find the "M1". I am at my wit's end now, for I am sure there is a simple solution to account for such scenario. Is there any alternative? Also, the matlab running in my campus has no symbolic toolbox, so it would best to avoid it. %Stagnant Pressure Ratio After Shockwaves %Stagnant Pressure Ratio Before Shockwaves Updated with a demonstration: % Mach Number after Shockwaves Normally, I would use "if" to account for different scenarios, but the increasing number of variables in the equation would increase the number of lines as well. I have a task of creating a matlab program, and I was searching for "switch" and "if" functions for the task.Īnd the user will define any two of the variables, then matlab will solve for the other one.
