kartik
2007-01-23 01:28:07 UTC
Dear Users
I have a function in MATLAB that I wanted to convert into Scilab. (read
at the end of this post !)
It involves a basic symbolic math application in MATLAB.
I am in the process of moving away from MATLAB completely, so I am
finding some problems during my migration.
Can anyone point me in the right direction ? or atleast suggest a user
manual that will give me some pertinent information.
Warm regards
kartik
% Function to calculate Mach Number for a given Exit-to-throat Area
ratio
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% for a nozzle.
%~~~~~~~~~~~~~~
% Author - Kartik Bulusu
% Doctoral Candidate, Department of Mechanical and Aerospace
Engingeering
% The George Washington University
% Date Created: 18/01/07 6:57pm
% Modifications: 1. 18/01/07 6:57pm - Added as function to flugel.m
function [Mp] = area_mach_rel(Ar_p, gamma_p)
syms Ar M k
f = ((2/(k+1))*(1+((k-1)/2)*M^2))^((k+1)/(k-1))-((Ar^2)*(M^2));
f = subs(f, {Ar,k}, [Ar_p, gamma_p]);
% x = solve('1.5^2 = (1/M^2)*((2/2.4)*(1+(0.4/2)*M^2))^(2.4/0.4)')
% >> syms a b c %declare variables
% >> f = a + b + c;
% >> subs(f, a, 3)
% ans = 3+b+c
[Mp] = solve(f,M);
for i=1:length(Mp)
if isreal(Mp(i)) == 0
Mp(i) = 0;
else
disp('Cleaning up extraneous solutions for Primary Flow Mach
Number... ')
end
end
Mp = sort(Mp);
Mp = [Mp(length(Mp)); Mp(length(Mp)-1)];
I have a function in MATLAB that I wanted to convert into Scilab. (read
at the end of this post !)
It involves a basic symbolic math application in MATLAB.
I am in the process of moving away from MATLAB completely, so I am
finding some problems during my migration.
Can anyone point me in the right direction ? or atleast suggest a user
manual that will give me some pertinent information.
Warm regards
kartik
% Function to calculate Mach Number for a given Exit-to-throat Area
ratio
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% for a nozzle.
%~~~~~~~~~~~~~~
% Author - Kartik Bulusu
% Doctoral Candidate, Department of Mechanical and Aerospace
Engingeering
% The George Washington University
% Date Created: 18/01/07 6:57pm
% Modifications: 1. 18/01/07 6:57pm - Added as function to flugel.m
function [Mp] = area_mach_rel(Ar_p, gamma_p)
syms Ar M k
f = ((2/(k+1))*(1+((k-1)/2)*M^2))^((k+1)/(k-1))-((Ar^2)*(M^2));
f = subs(f, {Ar,k}, [Ar_p, gamma_p]);
% x = solve('1.5^2 = (1/M^2)*((2/2.4)*(1+(0.4/2)*M^2))^(2.4/0.4)')
% >> syms a b c %declare variables
% >> f = a + b + c;
% >> subs(f, a, 3)
% ans = 3+b+c
[Mp] = solve(f,M);
for i=1:length(Mp)
if isreal(Mp(i)) == 0
Mp(i) = 0;
else
disp('Cleaning up extraneous solutions for Primary Flow Mach
Number... ')
end
end
Mp = sort(Mp);
Mp = [Mp(length(Mp)); Mp(length(Mp)-1)];