Code covered by the BSD License  

Highlights from
SMATLINK - Let Matlab Dance with Mathematica

image thumbnail
from SMATLINK - Let Matlab Dance with Mathematica by Yi Chen
Matlab (Frontend) call Mathematica Kernel

SMAT_matlabcall_casetest.m
% /*M-FILE SCRIPT SMAT_MATLABCALL_CASETEST MMM SMATLINK */ %
% /*==================================================================================================
%  Simple MATlab and MAThematica LINK laboratory Toolbox for Matlab 7.x
%
%  Copyright 2009 The SxLAB Family - Yi Chen - leo.chen.yi@gmail.com
% ====================================================================================================
% File description:
%
%             To build all the math test cases, same results as SMAT_matlabcall_casetest.nb
%
% [Input, Output] = SMAT_matlabcall(Input);
%
%Exampe:
%
%  [Input,Output]=SMAT_matlabcall('$System')
%
% Input = $System
%
% Output = Microsoft Windows (32-bit)
%
%Appendix comments:
%
% 1) http://reference.wolfram.com/mathematica/guide/Mathematica.html
% 2) http://reference.wolfram.com/mathematica/guide/AlphabeticalListing.html
% 3) SMAT_matlabcall_casetest.m file layout:
% 
% Section [1]  Core Language -- The uniquely powerful symbolic language that is the foundation for Mathematica
% [1-1] Open link
% [1-2] System Information
% [1-3] String Manipulation
%  [1-4] Debug 
%Section [2] Mathematics and Algorithms -- The world's largest integrated web of mathematical capabilities and algorithms
% [2-1] Numberical
% [2-2] Symbol
% [2-3] Euqation
% 
% Section [3] Visualization and Graphics -- Symbolic graphics and unparalleled function and data visualization
% 
% Section [4] Dynamic Interactivity -- Capabilities that define a new kind of dynamic interactive computing
% 
% Section [5] Systems Interfaces & Deployment -- Unique customizability and connectivity powered by symbolic programming
% 
% Section [6] Data Handling & Data Sources -- Powerful primitives and sources for large volumes of data in hundreds of formats
% 
% Section [7] Notebooks and Documents -- Program-constructible symbolic documents with uniquely flexible formatting.
% 
% Section [8] Module[{x = x0, y = y0, ...}, body]
% [8-1] Function
% [8-2] Module
% 
% Section [9] Block[{x = x0, y = y0, ...}, body]
% 
% Section [10] Advanced NDSolve[] Application of NDSolve`StateData for Dynamical Application Solve
% 
% Section [11] Applications
% [11-1] MMET5DOF test
%
% Reference:
% [1] Questions About Mathematica
%       - Systems and Installation
%       - Passwords
%       - Kernels and Programming
%       - Notebook Interface
%       - Mathematics
%       - Graphics and Sound
%       - Data Paclets
%       - Packages
%       - MathLink
%       - J/Link
%       - .NET/Link
%       - International
%       - Reference Information
%       - Books About Mathematica
% http://support.wolfram.com/mathematica/
%===================================================================================================
%  See Also:
%                    SMAT_matlabcall_casetest.nb
%===================================================================================================
%
%===================================================================================================
%Revision -
% Date                Name                    Description of Change
% 21-Nov-2008  Yi Chen                 Initial
%HISTORY$
%==================================================================================================*/

% SMAT_MATLABCALL_CASETEST Begin

% this part is to test matlab call mathematica via mex and mathlink
% make sure proper smat_matlabcall.dll or
%                  smat_matlabcall.mexw32
% is in folder of .\smat_matlabcall\outputs

home;
clear;
computer;
profile off;
feature('memstats');
% set path
% cd outputs

%switch on profile 
% http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/
% helpdesk/help/techdoc/ref/profile.html&http://newsgroups.derkeiler.com/Archive/Comp/comp.soft-sys.matlab/2008-04/msg03968.html
% profile on -detail 'builtin'  -history -timer 'real'
% profile('status') 

disp('************* SMATLINK Simulation Time Tag -- Begin *************')
SMAT_time_tag = datestr(now)

SMAT_matlabcall('help')

%%Section [1]  Core Language -- The uniquely powerful symbolic language that is the foundation for Mathematica
% [1-1] Close a link
% No.1
SMAT_matlabcall('Close')

% [1-2] System Information
% [1] http : // reference.wolfram.com/mathematica/guide/SystemInformation.html
% [2] http://reference.wolfram.com/mathematica/ref/Monitor.html
% No.2
SMAT_matlabcall('$Version')
% No.3
SMAT_matlabcall('$System')
% No.4
SMAT_matlabcall('$MachineType')
% No.5
SMAT_matlabcall('$OperatingSystem')
% No.6
SMAT_matlabcall('$CommandLine')
% No.7
SMAT_matlabcall('$Path')
% No.8
SMAT_matlabcall('$UserBaseDirectory')
% No.9
SMAT_matlabcall('$ExportFormats')
% No.10
SMAT_matlabcall('$Context')
% No.11
SMAT_matlabcall('$ContextPath')
% No.12
SMAT_matlabcall('SystemInformation[]')
% No. 13
SMAT_matlabcall('$VersionNumber')
% No. 14
SMAT_matlabcall('$LicenseID')
SMAT_matlabcall('$TimeZone')
SMAT_matlabcall('DateString[]')

% [1-3] String Manipulation
% http://reference.wolfram.com/mathematica/ref/StringReplace.html
% SMAT_matlabcall('StringReplace["abbaabbaa", "ab" -> "X"]')
% SMAT_matlabcall('StringReplaceList["ccccc", "c" -> "XYX"]')
% SMAT_matlabcall('StringCases["abcadcacb", "a" ~~ _ ~~ "c"]')

% [1-4] Debug 
% SMAT_matlabcall('<< AuthorTools`')
% SMAT_matlabcall('OpenAuthorTool[]')
% SMAT_matlabcall('?? AuthorTools`*`*')
% SMAT_matlabcall('values1 = {}; values2 = {}; Monitor[ NDSolve[{x'' ''[t] + Sin[x[t]] == 0, x[0] == 1, x''[0] == 0}, x, {t, 0, 2*3.14}, EvaluationMonitor :> (AppendTo[values1, {t, x[t]}];    AppendTo[values2, {t, x''[t]}]; Pause[0.05];),   Method -> "Extrapolation"], ListPlot[{values1, values2}]]')
% SMAT_matlabcall('LU[A_, p_: 0] := Block[{m, n, L, U}, {m, n} =  Dimensions[A]; {L, U} = {IdentityMatrix[n], A};  Do[Pause[p]; L[[k ;; n, k]] = U[[k ;; n, k]]/U[[k, k]];    U[[(k + 1) ;; n, k ;; n]] =     U[[(k + 1) ;; n, k ;; n]] -      L[[(k + 1) ;; n, {k}]].U[[{k}, k ;; n]];   , {k, 1, n - 1}];  {L, U}]')
% SMAT_matlabcall('Monitor[LU[{{1, 2, 3}, {4, 5, 7}, {6, 8, 9}}, 1],MatrixForm /@ {L, U}]')
% SMAT_matlabcall('Monitor[LU[RandomReal[1, {10, 10}], .3];, MatrixPlot /@ {L, U}]')

%  SMAT_matlabcall('FindMinimum[Exp[x] + 1/x, {x, 1}, StepMonitor :> Print["Step to x = ", x]]')
SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('f[x_] = Exp[x] + 1/x;{res, steps} = Reap[FindMinimum[f[x], {x, 3}, StepMonitor :> Sow[{x, f[x]}]]]')
SMAT_matlabcall('SMATgraphIdentity = Plot[f[x], {x, .1, 1.5}, Epilog -> {Red, Map[Point, steps[[1]]]}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall(' fac[n_] := n*fac[n - 1]; ')
% SMAT_matlabcall('  fac[1] ')
% SMAT_matlabcall('Trace[(k = 2; For[i = 1, i < 4, i++, k = i/k]; k), k = _]')
% SMAT_matlabcall('Trace[fac[3], fac[n_]]')
% SMAT_matlabcall('Trace[fac[3], fac[n_]]')
% SMAT_matlabcall('Trace[fac[10], 120, TraceBackward -> True]')
% SMAT_matlabcall('Trace[Module[{x}, x = 5], x = _]')
% SMAT_matlabcall('Trace[Module[{x}, x = 5], x = _, MatchLocalNames -> False]')

% SMAT_matlabcall('TracePrint[(2 + 3)^2]')
% SMAT_matlabcall('TracePrint[fib[5], Plus[__Integer?Positive]]')

% SMAT_matlabcall('TraceScan[Print, f[1, 2 + 3]]')
% SMAT_matlabcall('Block[{c = 0}, {TraceScan[c++ &,FixedPoint[(#/2 + 1/#) &, 1.], (Plus | Times)[__?MachineNumberQ]],  c}] ')

%%Section [2] Mathematics and Algorithms -- The world's largest integrated web of mathematical capabilities and algorithms
%%[2-1] Numberical
% No.10
SMAT_matlabcall('1+1')
SMAT_matlabcall('3.4 + 7.6')
SMAT_matlabcall('1*10*1000.1')
SMAT_matlabcall('10/2.5')
SMAT_matlabcall('Sin[Pi]')
SMAT_matlabcall('Sin[0]')
SMAT_matlabcall('Sin[Pi/3]')
SMAT_matlabcall('N[Pi,20]')

SMAT_matlabcall('Sum[2i-1,{i,1,9}]')
SMAT_matlabcall('Sum[1/n!,{n,1,11}]')

SMAT_matlabcall('Limit[Sqrt[x^2+2]/(3x-6),x->Infinity]')
SMAT_matlabcall('D[Exp[x]*Sin[x],{x,2}]')

SMAT_matlabcall('NIntegrate[Exp[-x^2], {x, 0, Infinity}]')

%%[2-2] Symbol
SMAT_matlabcall('Integrate[Log[x]^(3/2),x]')
SMAT_matlabcall('InputForm[Integrate[Log[x]^(3/2), x]]')
SMAT_matlabcall('exactHilbert = Table[1/(i+j-1),{i,2},{j,2}]')
SMAT_matlabcall('N[Det[exactHilbert], 40]')

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Plot[Evaluate@Through[{Identity, Exp, Log}[x]], {x, -2, 2}, AspectRatio -> Automatic, PlotRange -> 2]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

% x^4 in Mathematica = '4\012x' in Matlab
SMAT_matlabcall('x^4')

% (x+y)^4 in Mathematica = '4\012(x + y)' in Matlab
SMAT_matlabcall('(x+y)^4')

SMAT_matlabcall('Expand[(x+y)^4*(x+y^2)]')

% x^5 + 4*x^4*y + 6*x^3*y^2 + x^4*y^2 + 4*x^2*y^3 + 4*x^3*y^3 + x*y^4 +
% \012 6*x^2*y^4 + 4*x*y^5 + y^6
SMAT_matlabcall('Expand[(x+y)^4*(x+y^2)]// InputForm')

SMAT_matlabcall('InputForm[Expand[(x+y)^4*(x+y^2)]]')
SMAT_matlabcall('InputForm[Expand[(x+y)^4(x+y^2)]]')

SMAT_matlabcall('InputForm[Expand[(x+y)^4]]')
SMAT_matlabcall('InputForm[Expand[(x+y^2)]]')

SMAT_matlabcall('D[Sin[x*y^2],x,x]')
SMAT_matlabcall('Nest[Function[t,1/Sqrt[1+t]],x,2]')

SMAT_matlabcall('PolynomialQuotient[x^2, 1+2x,x]')
SMAT_matlabcall('PolynomialRemainder[x^2, 1+2x,x]')

SMAT_matlabcall('Pi')
SMAT_matlabcall('E')
SMAT_matlabcall('m = Table[2^i + x^j, {i, 3}, {j, 4}]')
SMAT_matlabcall('MatrixForm[m]')

SMAT_matlabcall('CForm[1 + 2 x + 3 x^2]')
SMAT_matlabcall('FortranForm[1 + 2 x + 3 x^2]')
SMAT_matlabcall('TeXForm[a + b^2]')
SMAT_matlabcall('InputForm[1 + 2 x + 3 x^2]')

% SMAT_matlabcall('TraditionalForm[D[f[x, y], {x, 2}, {y, 3}]]');
%%[2-3] Euqation
SMAT_matlabcall('Solve[x^3 - 2*x + 1 == 0]')
SMAT_matlabcall('Solve[{2*x+3*y==9,x-2*y==1},{x,y}]')

SMAT_matlabcall('Solve[a*x^2 + b*x + c == 0, x]')
SMAT_matlabcall('Reduce[a*x^2+b*x+c==0,x]')

SMAT_matlabcall('FindRoot[3*Cos[x]==Log[x],{x,1}]')
SMAT_matlabcall('Plot[{3*Cos[x],Log[x]},{x,1,15}]')
SMAT_matlabcall('FindRoot[3*Cos[x]==Log[x],{x,5}]')

SMAT_matlabcall('Roots[x^2-3x+3==0,x]')

%Pay Attension here:
%In Mathematica -    y'[x]
%In Matlab      -  ' y''[x]'
SMAT_matlabcall('DSolve[y''[x] + y[x] == a Sin[x], y[x], x]')

SMAT_matlabcall('NDSolve[{y''[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}]')


SMAT_matlabcall('NSolve[x^5 - 6 x^3 + 8 x + 1 == 0, x]')
% SMAT_matlabcall('Plot[Evaluate[{y[x], y''[x], y''''[x]} /. s], {x, 0,30}, PlotStyle -> Automatic]');

SMAT_matlabcall('NDSolve[{x''''[t] + x[t]^3 == Sin[t], x[0] == x''[0] == 0}, x, {t, 0, 50}]')
SMAT_matlabcall('ParametricPlot[Evaluate[{x[t], x''[t]} /. %], {t, 0, 50}]')

% [2-4] Integrated Data Sources
% http://reference.wolfram.com/mathematica/guide/DataCollections.html

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =  GraphData["PappusGraph"]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =  GraphicsGrid[Partition[GraphData /@ GraphData["CayleyGraph"], 7]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =  ListPlot[Tooltip[GraphData[#, {"EdgeCount", "VertexCount"}],  GraphData[#, "StandardName"]] & /@ GraphData[]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =  ListPlot[GraphData["Crown", {"EdgeCount", "VertexCount"}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);


SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =  ListLinePlot[Table[Length[GraphData[n]], {n, 50}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =  PolyhedronData[{"Antiprism", 5}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = GraphPlot[{1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2,  4 -> 1, {4 -> 2, "4\[Rule]2"}, 4 -> 4}, VertexLabeling -> True]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =GraphPlot3D[{1 -> 2, 1 -> 3, 1 -> 4, 1 -> 5, 2 -> 3, 2 -> 4, 2 -> 5, 3 -> 4, 3 -> 5, 4 -> 5}, VertexLabeling -> True]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =GraphPlot3D[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 1, 4 -> 5, 5 -> 1, 2 -> 5, 3 -> 5}, EdgeRenderingFunction -> (Cylinder[#1, .05] &), VertexRenderingFunction -> ({ColorData["Atoms"][ RandomInteger[{1, 117}]], Sphere[#1, .15]} &), PlotStyle -> Directive[Specularity[White, 20]]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =LayeredGraphPlot[{1 -> 2, 1 -> 3, 2 -> 3, 1 -> 4, 2 -> 4, 1 -> 5}, Left]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity =Graphics3D[{Opacity[.5], FaceForm[Yellow], PolyhedronData["SnubCube", "Faces"]}, Lighting -> "Neutral"]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = RegionPlot3D[x^2 + y^3 - z^2 > 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = RegionPlot3D[x y z < 1, {x, -5, 5}, {y, -5, 5}, {z, -5, 5},  PlotStyle -> Directive[Yellow, Opacity[0.5]], Mesh -> None]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = ContourPlot3D[ x^4 + y^4 + z^4 - (x^2 + y^2 + z^2)^2 + 3 (x^2 + y^2 + z^2) ==  3, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, Mesh -> None, ContourStyle -> Directive[Orange, Opacity[0.8], Specularity[White, 30]]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = ListContourPlot3D[Table[x^2 + y^2 - z^2 + RandomReal[0.1], {x, -2, 2, 0.2}, {y, -2, 2,   0.2}, {z, -2, 2, 0.2}], Contours -> 3, Mesh -> None, ContourStyle -> {Red, Orange, Yellow}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = ListContourPlot[Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = ListDensityPlot[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 2, 1, 4}}, Mesh -> All]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},ColorFunction -> "CMYKColors", PlotPoints -> 35, MeshFunctions -> {#3 &, #3 &}, Mesh -> {Range[-1, 1, 0.4], Range[-0.8, 0.8, 0.4]}, MeshStyle -> {Black, Dashed}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);


SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = RevolutionPlot3D[t^4 - t^2, {t, 0, 1}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Graphics[Circle[], Frame -> True, GridLines -> Automatic] Graphics[Circle[], Frame -> True, GridLines -> Automatic, GridLinesStyle -> Directive[Orange, Dashed]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Grid[Table[x, {4}, {7}], Frame -> All]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = PolarPlot[Sin[3 t], {t, 0, Pi}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = ListPolarPlot[Table[Sqrt[n], {n, 100}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = ListPolarPlot[Table[{n, Log[n]}, {n, 500}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

%%Section [3] Visualization and Graphics -- Symbolic graphics and unparalleled function and data visualization
SMAT_matlabcall('Plot3D[Sin[x*y], {x, 0, 4}, {y, 0, 4}]')
SMAT_matlabcall('Plot[Sin[x^2],{x,-Pi,Pi}]')
SMAT_matlabcall('Plot[{Sin[x],Sin[2x],Sin[3x]},{x,0,2Pi},PlotStyle->{RGBColor[0.9,0,0], RGBColor[0,0.9,0], RGBColor[0,0,0.9]}]')


SMAT_matlabcall('ParametricPlot[{Sin[3 t] Cos[t], Sin[3 t] Sin[t]}, {t, 0, 2 Pi}]')
SMAT_matlabcall('ParametricPlot[{{Sin[3t]Cos[t],Sin[3t]Sin[t]},{Sin[t],Cos[t]}},{t,0,2Pi},AspectRatio->Automatic]')

SMAT_matlabcall('St=Table[Rectangle[{x,0},{x+0.08,Sin[x]}],{x,0,2Pi,0.15}]')
SMAT_matlabcall('Show[Graphics[St],Axes->True]')

SMAT_matlabcall('SphericalPlot3D[1 + 1/5 Sin[3 v], {u, 0, Pi}, {v, 0, 2 Pi}]')

SMAT_matlabcall('{ParametricPlot[{u Cos[u], u Sin[u]}, {u, 0, 4 Pi}],ParametricPlot[{(u + v) Cos[u], (u + v) Sin[u]}, {u, 0, 4 Pi}, {v, 0,3}]}')

SMAT_matlabcall('{ParametricPlot3D[{Sin[u] Cos[v], Sin[u] Sin[v], Cos[u]}, {u, 0, Pi}, {v, -Pi, Pi + 3 Pi/4}, PlotStyle -> Opacity[0.5]], ParametricPlot3D[{Sin[u] Cos[v], Sin[u] Sin[v], Cos[u]}, {u, 0, Pi}, {v, -Pi, Pi + 3 Pi/4}, ColorFunction -> Function[{x, y, z, u, v}, Hue[v]]]}')

SMAT_matlabcall('Plot[Sin[x] + Sin[Sqrt[x]], {x, 0, 500 Pi}]')

% SMAT_matlabcall(' CreateWindow[ DocumentNotebook[{Section 3 - Visualization and Graphics}, WindowTitle -> "Section 3 - Visualization and Graphics"]]')
SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Plot3D[Evaluate[Table[Tooltip[Sin[x + n y],Plot[Sin[n x], {x, 0, 2 Pi}, Filling -> Axis,FillingStyle -> Pink, ImageSize -> 200]], {n, 3}]], {x, 0, 3}, {y, 0, 3}, PlotStyle -> Table[Opacity[.7, Hue[i/6]], {i, 4}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Graphics3D[ Table[{Hue[RandomReal[]], Opacity[RandomReal[]],  Specularity[White, 20], Sphere[RandomReal[6, 3]]}, {50}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.gif');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = With[{p = RandomReal[15, {50, 3}]},Graphics3D[{Thick, Line[p[[Last[FindShortestTour[p]]]]], Opacity[.3], Sphere /@ p}]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

%%Section [4] Dynamic Interactivity -- Capabilities that define a new kind of dynamic interactive computing
% Reference:
% [1] http://reference.wolfram.com/mathematica/tutorial/IntroductionToDynamic.html
% [2] http://reference.wolfram.com/mathematica/tutorial/AdvancedDynamicFunctionality.html
% [3] http://reference.wolfram.com/mathematica/guide/DynamicVisualization.html
% [4] http://reference.wolfram.com/mathematica/guide/LowLevelInterfaceControl.html
% [5] http://reference.wolfram.com/mathematica/guide/ControlObjects.html
SMAT_matlabcall('Manipulate[ControlActive[u, u Range[4]], {u, 0, 1}]')

SMAT_matlabcall('Manipulate[ControlActive[u, Graphics[Circle[{0, 0}, u], PlotRange -> 2]], {u, 0,1.5}]')

SMAT_matlabcall('Manipulate[ Plot[Sin[1/(x - a)], {x, 0, 1}, PlotPoints -> ControlActive[5, 50], PlotRange -> 1], {a, 0, 1}]')

SMAT_matlabcall('Manipulate[ Plot3D[Sin[a x] Sin[b y], {x, 0, 3}, {y, 0, 3},PerformanceGoal -> ControlActive["Speed", "Quality"],  PlotRange -> 1], {a, 1, 3}, {b, 1, 3}]')

SMAT_matlabcall('Manipulate[Table[(n + m)/n!, {n, 1, 10}], {m, 1, 10, 1}]')
    
SMAT_matlabcall('{DynamicModule[{x = .5}, {Slider[Dynamic[x]], Dynamic[Plot[Sin[10 y x], {y, 0, 2 Pi}]]}], DynamicModule[{x = .5}, {Slider[Dynamic[x]],    Dynamic[Plot[Tan[10 y x], {y, 0, 2 Pi}]]}]}')

SMAT_matlabcall('DynamicModule[{n = 3}, Column[{Slider[Dynamic[n], {3, 1000, 1}],   Dynamic[Graphics[ControlActive[Inset[n, {0, 0}],     Line[Table[{{0, 0}, {Cos[t], Sin[t]}}, {t, 0., 2 Pi, 2 Pi/n}]]],ImageSize -> 300, PlotRange -> 1], SynchronousUpdating -> Automatic]}]]')

SMAT_matlabcall('Dynamic[Pause[3]; Style["Hello", 100], SynchronousUpdating -> False]')

SMAT_matlabcall('Interpretation[{f = Sin[x], min = 0, max = 2 Pi},Panel[Grid[{{Style["Plot", Bold], SpanFromLeft}, {"Function:",InputField[Dynamic[f]]}, {"Min:", InputField[Dynamic[min]]}, {"Max:", InputField[Dynamic[max]]}}]],  Plot[f, {x, min, max}]]')
  
SMAT_matlabcall('Interpretation[{f = x^2, var = x, min = a, max = b},Panel[Row[{Underoverscript[Style["\[Integral]", 36], InputField[min, FieldSize -> Tiny], InputField[max, FieldSize -> Tiny]],   InputField[f, FieldSize -> {{10, Infinity}, {1, Infinity}}], " \[DifferentialD] ", InputField[var, FieldSize -> Tiny]}]], Integrate[f, {var, min, max}]]')

% SMAT_matlabcall('CurrentValue["MousePosition"]')

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Plot[{Hyperlink[Sin[x], "http://mathworld.wolfram.com/Sine.html"],Hyperlink[Cos[x], "http://mathworld.wolfram.com/Cosine.html"]}, {x, 0, 2 Pi}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('TreeForm[a + b^2 + c^3 + d]')
%%Section [5] Systems Interfaces & Deployment -- Unique customizability and connectivity powered by symbolic programming
% SMAT_matlabcall('ControllerManipulate[Plot[{Sin[x + a] + b, Sinc[x + c] + d}, {x, -2 Pi, 2 Pi},PlotRange -> 2], {a, 0, 10}, {b, 0, 1}, {c, 0, 10}, {d, 0, 1}]')

SMAT_matlabcall('clock[{h_, m_, s_}] :=  Graphics[{Table[Text[t, 0.9 {Sin[t Pi/6], Cos[t Pi/6]}], {t, 1, 12}], Circle[], Green, Rotate[Line[{{0, 0}, {0, 0.9}}], (-2 Pi) s/60, {0, 0}], Blue, Rotate[Line[{{0, 0}, {0, 0.8}}], (-2 Pi) (m + s/60)/60, {0, 0}],   Rotate[Line[{{0, 0}, {0, 0.4}}], (-2 Pi) Mod[h + m/60, 12]/12, {0, 0}]}]')
% SMAT_matlabcall(' CreateDialog[Dynamic[DateString[], UpdateInterval -> 1, Deinitialization :> CreateDialog[clock@Take[DateList[], -3]]]]')

SMAT_matlabcall('ControllerInformation[]')

SMAT_matlabcall('clock[{h_, m_, s_}] :=Graphics[{Table[Text[t, 0.9 {Sin[t Pi/6], Cos[t Pi/6]}], {t, 1, 12}], Circle[], Green, Rotate[Line[{{0, 0}, {0, 0.9}}], (-2 Pi) s/60, {0, 0}], Blue, Rotate[Line[{{0, 0}, {0, 0.8}}], (-2 Pi) (m + s/60)/60, {0, 0}],  Rotate[Line[{{0, 0}, {0, 0.4}}], (-2 Pi) Mod[h + m/60, 12]/12, {0, 0}]}]')
SMAT_matlabcall(' OpenerView[{Dynamic[DateString[], UpdateInterval -> 1], Dynamic[clock@Take[DateList[], -3], UpdateInterval -> 1]}]')

%%Section [6] Data Handling & Data Sources -- Powerful primitives and sources for large volumes of data in hundreds of formats
SMAT_matlabcall('Factor[x^99 + y^99]')
SMAT_matlabcall('Simplify[%]')
SMAT_matlabcall('Range[10] ')
SMAT_matlabcall('Table[2i+j,{i,1,3},{j,3,5}]')
SMAT_matlabcall('Play[Sin[10000/ t], {t, 0, 2}]')

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = ArrayPlot[CellularAutomaton[{1635, {3, 1}}, {{1}, 0}, 80]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = MatrixPlot[ Fourier[Table[ UnitStep[i, 4 - i] UnitStep[j, 7 - j], {i, -50, 50}, {j, -50, 50}]]]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

% http://reference.wolfram.com/mathematica/DatabaseLink/tutorial/Overview.html
% http://reference.wolfram.com/mathematica/DatabaseLink/tutorial/TheDatabaseExplorer.html
SMAT_matlabcall('DatabaseExplorer[]')

%%Section [7] Notebooks and Documents -- Program-constructible symbolic documents with uniquely flexible formatting.
SMAT_matlabcall('cfile = $TemporaryPrefix <> "SMAT_cfile_test.mf"')
SMAT_matlabcall('Write[cfile, OutputForm["y = <* D[x^x, x] *>"]]')
SMAT_matlabcall('Close[cfile]')
SMAT_matlabcall('FilePrint[cfile]')

SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('Export["SMATexporttest.dat", {{5.7, 4.3}, {-1.2, 7.8}}]')
SMAT_matlabcall('FilePrint["SMATexporttest.dat"]')
% get current opened file path
% SMAT_matlabcall('SetDirectory[ToFileName@("FileName"/.NotebookInformation[EvaluationNotebook[]] /. {"FileName" ->""})[[1]]]')
SMAT_matlabcall('SetDirectory["C:/Temp/SMATLINK/SMAT_matlabcall/outputs"]');
SMAT_matlabcall('SMATgraphIdentity = Plot[Sin[x] + Sin[1.6 x], {x, 0, 40}]')
SMAT_matlabcall('Export["SMATgraphIdentity.eps", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.jpg", SMATgraphIdentity]')
SMAT_matlabcall('Export["SMATgraphIdentity.gif", SMATgraphIdentity]')
SMAT_matlabcall('Import["SMATgraphIdentity.gif"]')

SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/outputs/SMATgraphIdentity.jpg');
imshow(SMAT_moon);

SMAT_matlabcall('Import["C:/Temp/SMATLINK/SMAT_matlabcall/test/SMATLINK-logo.jpg"]');
SMAT_moon = imread('C:/Temp/SMATLINK/SMAT_matlabcall/test/SMATLINK-logo.jpg');
imshow(SMAT_moon);

%%Section [8] Module[{x = x0, y = y0, ...}, body]
%%[8-1] Function
SMAT_matlabcall('f[x_]=x*Sin[x]+x^2')
SMAT_matlabcall('f[1]')
SMAT_matlabcall('Plot[f[x],{x,-3,3}]')

SMAT_matlabcall('f[x_,y_ ]=x*y+y*Cos[x]')
SMAT_matlabcall('f[2,3]')

SMAT_matlabcall('f[x_]:=x-1/;x>=0')
SMAT_matlabcall('f[x_]:=x^2/;(x>-1)&&(x<0)')
SMAT_matlabcall('f[x_]:=x-1/;x<= -1')
SMAT_matlabcall('f[5]')

SMAT_matlabcall('f[x_] := Expand[x^2]')
SMAT_matlabcall('f[a + b]')


% the following 2 lines are not correct:
% step = '30'
% SMAT_matlabcall('Mean[ Table[Evaluate[y[t] /.solution], {t, 0, step}] ]')


SMAT_matlabcall('ClearAll["Global`*"]')
SMAT_matlabcall('Close')


SMAT_time_tag
disp('************* SMATLINK Simulation Time Tag -- End *************')

close('all');


% SMAT_MATLABCALL_CASETEST End

Contact us at files@mathworks.com