This tutorial was written by Carolina Penteado, University of Stuttgart and intern at Altair / Germany
Quick Introduction to HyperMath (Written by: Carolina M. e R. Penteado)
This document presents a list of HyperMath commands and language syntax which
can be used for mathematical operations and data analysis.
All the information is available with more details on the online HyperMath help
(D:\hw110_64\help\hmath\hmath.htm).
1. Vectors
Row vector a=[1 2 3]
a=[1, 2 ,3]
Column vector a=[1;2;3]
Interval a=[1:0.1:2]
Transposition v`
Vector length Length(a)
Element wise multiplication a.*b
2. Matrices
Matrix M=[1 2 3; 4 5 6]
Built matrix with column vectors M=[v1 v2 vn]
Built matrix with row vectors M=[v1;v2;vn]
Matrix with zeros M=Zeros(m,n)
Matrix with ones M=Ones(m,n)
Scalar multiplication M*2
First row of M M(1,:)
Second row of M M(:,2)
Size of M Size(M)
Eigenvalues EigS(A)
EigSB(A)
EigST(A)
Inverse V^-1
Inv(V)
Determinant Det(M)
Rank Rank(M,tol)
A/B equivalent to A*inv(B), where inv means
Foward Division inversion
Backward division A\B
1
3. Polynomials
Polynom roots PolyRoots(c)
Polynom evaluation PolyVal(c,x)
4. Complex numbers
Complex numbers z=-3+4*i
Real part Real(z)
Imaginary part Imag(z)
5. Trigonometric functions
Sin(t) y=Sin(t)
Cos(t) y=Cos(t)
6. Graphics
Plot line curves PlotLine(t,y) and PlotLine3D(x,y,z)
Plot scatter curves PlotScatter(t,y) and PlotScatter3D(x,y,z)
Plot vertical bars PlotBar(x,y,[s])
Plot surface PlotSurface3D(x,y,z) and PlotWaterfall3D(x,y,z)
Plot contours PlotContour(x,y,z) and PlotContour3D(x,y,z)
Plot area PlotArea(x,y)
Plot phase and magnitude in polar
coordinates PlotPolar(p,m,[s])
Graphic x label SetXLabel()
Graphic y label SetYLabel()
Graphic title SetTitle()
Graphic legend SetLegend()
Adjust axis SetXRange() , SetYRange() SetZTRange()
7. System commands
Clear variable Clear('variable_name')
Clear all variables ClearAll()
Delete all plots DeleteAllPlots()
Delete one plot DeletePlot('plot_name')
2
8. Scripts
Write comments // line with comments
or
/* more
than one line with comments */
9. Control structures
For Loop for i=1,10,2 do
end
While Loop while i>10 do
end
If Condition if (i>10) {
}
elseif (i<10){
}
else{
}
end
10. Functions
Define function function function_name(input1,input2,...,input n){
function body
return output;
}
Call function y=function_name(input1,input2,...,input n);
11. Numerical solution of diferential equations
Adams method and functional iteration y=ODE11("equation_name", init, x)
Backward differential method y=ODE21("equation_name", init, x)
and functional iteration
Backward differential y=ODE22a("equation_name", init, x)
and newton iteration for dense matrix
Runge-Kutta fourth-order method y=RK45("equation_name", init, x)
Backward differential method y=DAE11a("equation_name", init, x)
and newton iteration
3
12. Representation of systems and system response
Convert transfer function to state space SSFromTF(Num,Den)
Simulate system response LSim()
13. Strings
Convert String to number tonumber(namestring)
Split string part1, part2 = StrTok(string);
Format string string.format(formatstring, e1, e2, ...)
14. Reading/writing files
Read .txt file fileid=Open("/patch/filename.txt","r")
line=fileid::read()
Close(fileid)
Write .txt file filenew=Open("/patch/filename.txt","w")
Fwrite(filenew, Data)
Close(filenew)
Fwrite only if Data=Matrix