数组存储顺序
-->a = [1:3;4:6];
-->disp(a);
1 2 3
4 5 6
他在内存的存储顺序是
【1,4,2,5,3,6】
可以认为是转秩存储的。
字符串
t=sci2exp(a [,nam] [,lmax]) // converts an expression to a string
[out,in,text]=string(x)
strcat - catenate character strings
length()
[nr,nc]=size(x)
ind=strindex(str1,str2)
printf(format,value_1,…,value_n)
str=sprintf(format,value_1,…,value_n)
sci2exp(poly([1 0 3 4],'s'),'fi')
x=123.356; 'Result is '+string(x)
strcat(string(1:10),',')
['this','is'; 'a 2x2','matrix'] "matrix"=="mat"+"rix"
k=strindex('SCI/demos/scicos','/')
xnumb(x,500*ones(x),[10,20,35],1)
xstring(0.1,0.1,alphabet)
printf('Result is:\nalpha=%f",0.535)
sprintf('%3d Fahrenheit = %6.1f Celsius',fahr,(5/9)*(fahr-32))
函数操作
[H]= eval(Z) evaluation of a matrix of strings
evstr - evaluation of expressions
find - find indices of boolean vector or matrix true elements
function [y1,…,yn]=foo(x1,…,xm)
function [y1,…,yn,varargout]=foo(x1,…,xm,varargin)
[f,e]=frexp(x)
deff("[ydot]=f(t,y)","ydot=y^2-y*sin(t)+cos(t)")
y0=0;t0=0;t=0:0.1:%pi;
y=ode(y0,t0,t,f)
plot(t,y)
a=1; b=2; Z=['a','sin(b)'] ; eval(Z) //returns the matrix [1,0.909];
a=1; b=2; Z=['a','b'] ; evstr(Z)
A=rand(1,20);
w=find(A<0.4)
A(w)
w=find(A>100)
[f,e]=frexp([1,%pi,-3,%eps])
//inline definition (see function)
function [x,y]=myfct(a,b)
x=a+b
y=a-b
endfunction
[x,y]=myfct(3,2)
//inline definition (see deff)
deff('[x,y]=myfct(a,b)',['x=a+b';
'y=a-b'])
// definition in an ascii file (see exec)
exec SCI/macros/elem/asin.sci;
// definition in an ascii file (see getf)
getf SCI/macros/elem/asin.sci;