Calc is small Matlab language interpreter. The applications supports only basic Matlab operations. I'm currently creating new interpeter from scratch with improved stability and performance.
Windows (32-bit): https://onedrive.live.com/redir?resid=E099E6685BF9AD4%21213167
- Boost 1.57
- Qt5
- Visual Studio 2013
- Qt Vs Addin
- DISLIN
double:
a=2+3i;
mpf_float (100 bit)
b=mpf_float(543e+45599999)
To create a string use two apostrophes:
string_variable = 'Hello world'
To create a matrix use fallowing instruction:
A = [1 3 -3 ; 1+10 3*10 3 ; [3 3 2]]
%or
A = [ 1 3 -3
1+10 3*10 3
[3 3 2]]
%mpf_float matrix
B = mpf_float(A);
Instructions can be separated by semicolon, comma or new line:
a=3+2i , b=2; d= 2 + ... continuing instruction in new line
3*10;
To prevent command result display use semicolon.
if (a==1)
c=2
elseif (3)
d=2
else
2
end
A=[];
for i=1:0.1:10
A(1,i)=i*i;
end
while i<10
i=i-1;
end
Inside loops 'break' and 'continue' keywords might be used.
Function must be declered in seperate ".m" file. The file name must be the same as a function name. File has to start with function declaration (see fallowing example).
function [out1,out2] = methodName(in1,in2,in3)
out1=in1*in2;
out2=in1+in3;
end
To exit function or script use 'return' keyword.
% Single line comment
%{ Multiline
comment %}
i = 1:10; % default step is always 1
ii = 1:0.1:10;
>> A = [1 ; 2 ; 3];
>> B = [ A [4 3; 5 4 ; 6 5] ]
B=
1 4 3
2 5 4
3 6 5
>> C = [ A ; [4 3; 5 4 ; 6 5] ]
Col: 28, Line: 1 Dimensions of matrices being concatenated are not consistent.
>> C = [ [ A [10 ; 11 ; 12-3 ] ] ; [4 3; 5 4 ; 6 5] ]
C=
1 10
2 11
3 9
4 3
5 4
6 5
rand(m)
rand(m,n)
eye(m,n)
ones(m,n)
zeros(m,n)
A(i,j)
A(i) (matrix A treated as column vector)
A(k:m,j)
A(:,j)
A(i,:)
A(end,i)
A(end+3,j)=10; (automatic matrx expansion)
To remove matrix entire rows or columns use fallowing command:
A(:,2:3) = [] %removing 2nd and 3rd column from A
A+B
A.+B
+A
A-B
A.-B
-A
A*B
A.*B
A/B (compute A*inv(B))
A./B
A\B (solves A*x=B)
A.\B
A^B
A.^B
A'
A.'
A==B
A~=B
A<B
A<=B
A>B
A>=B
expression1 | expression2
expression1 & expression2
expression1 || expression2 %(short-circuit OR operator, applied only to scalar arguments)
expression2 && expression2 %(short-circuit AND operator)
~negation
a=sqrt(A)
a=log(b) or a=log(b,c)
a=log2(c)
a=log10(d)
sin(A)
cos(A)
tan(A)
cot(A)
conj(3+2i) == 3-2i
det(A)
inv(A) == A^-1
x=url(A,b)
[L,U,P]=lu(A)
[m,n]=size(A)
a=length(C)
numel(A)
iscolumn(A)
isrow(A)
isempty(A)
isscalar(A)
isvector(A)
rows(A)
cols(A)
KLab can draw 2D and 3D plots using fallowing methods:
plot(x,y)
plot3(x,y,z)
mesh(x,y,z)
eps=2.2204e-16;
temp = -8:0.5:8;
[m,n]=size(temp);
x=[];
y=[];
for i=1:n
x(i,:) = temp;
y(i,:) = temp;
end
y=y';
R = (x.^2 + y.^2).^0.5 + eps;
Z = sin(R)./R;
mesh(x,y,Z);
clear % remove all variables
clear var1, var2, var3
clear ('var1','var2',...,'varN')
save file_name % save all variables
save file_name var1 var2 ... varN
load file_name % load all variables from file
load file_name var1 var2 ... varN
% plik def_fun.m
function d = det_fun(A)
if rows(A)~=cols(A)
error('A must be squere matrix!');
end
d=det(A);
end
% command line
>> det_fun(rand(3,7))
det_fun Col: 3, Line: 3 A must be squere matrix!