from
SMATLINK - Let Matlab Dance with Mathematica
by Yi Chen
Matlab (Frontend) call Mathematica Kernel
|
| SMAT_matlabcall_demo_script.m |
% /*M-FILE SCRIPT SMAT_MATLABCALL_DEMO_SCRIPT 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:
%
% An example for Calling Mathematica Kernel by Matlab Script m-file
%
%
% ans =
%
% 2\012x + x Sin[x]
%
%
% ans =
%
% 1 + Sin[1]
%
%
% ans =
%
% -Graphics-
%
%
% ans =
%
% SMATscript.jpg
%
%===================================================================================================
% See Also:
%
% SMAT_matlabcall_casetest.m
% SMAT_matlabcall_demo_function.m
%===================================================================================================
%
%
%===================================================================================================
%Revision -
% Date Name Description of Change
% 29-Jun-2008 Yi Chen Initial
%HISTORY$
%==================================================================================================*/
% SMAT_MATLABCALL_DEMO_SCRIPT Begin
clear
home
%define a function in mathematica
SMAT_matlabcall('f[x_]=x*Sin[x]+x^2')
%a test
SMAT_matlabcall('f[1]')
%generate figure in mathemaitca
%Attention,
% no '_' in figure file name,
% such as: SMAT_script.jpg, error will occur, may fix it later
SMAT_matlabcall('SMATmoon = Plot[f[x],{x,-3,3}]')
SMAT_matlabcall('Export["SMATscript.jpg", SMATmoon]')
%load and display figure in matlab
SMAT_moon = imread('SMATscript.jpg');
imshow(SMAT_moon)
SMAT_matlabcall('Close')
% SMAT_MATLABCALL_DEMO_SCRIPT End
|
|
Contact us at files@mathworks.com