Discussion:
Can scilab do symbolic math ?
(too old to reply)
kartik
2007-01-23 01:28:07 UTC
Permalink
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)];
Andreas Kochenburger
2007-01-24 17:25:46 UTC
Permalink
Perhaps I am mistaken, but I seem to remember that MuPad can do
symbolics together with Scilab

Andreas
n***@yahoo.com
2018-03-08 00:57:24 UTC
Permalink
Post by kartik
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 don't read french

Loading...