matlab集锦
来源:互联网 发布:五轴工具磨床编程软件 编辑:程序博客网 时间:2024/05/17 08:19
依然贴一个链接
http://3y.uu456.com/bp-17e6f009ba1aa8114431d93c-2.html
a=pi+sqrt(5) %一个数值
sa=sym('pi+sqrt(5)') %生成一个表达式
Ca=class(a)
Csa=class(sa)
vpa(sa-a) %这里可以说是运算,数值化。
当需要学习Matlab中一个函数的用法时,第一步就是help。
>> help feval;
FEVAL Execute the specified function.
FEVAL(F,x1,...,xn) evaluates the function specified by a function
handle or function name, F, at the given arguments, x1,...,xn.
FEVAL is usually used inside functions which take function
handles or function strings as arguments.
[y1,..,yn] = FEVAL(F,x1,...,xn) F是需要使用函数的函数名,或者句柄;xi是函数的参数,yi是函数的返回值
举例:
假设需要调用的函数foo定义如下:
function x=foo(a,b)
x=a*b;
若在main函数中用feval调用foo,可以有以下几种方式
1. result=feval('foo',3,15);
2. result=feval(@foo,3,16); %这里@foo即句柄
3. 若调用的函数要作为main的参数,则
function result=main(f)
result=feval(f,3,10);
然后调用main时将'foo'传入即可
>>main('foo');
matlab中repmat函数的用法
B = repmat(A,m,n)
B = repmat(A,[m n])
B = repmat(A,[m n p...])
这是一个处理大矩阵且内容有重复时使用,其功能是以A的内容堆叠在(MxN)的矩阵B中,B矩阵的大小由MxN及A矩阵的内容决定,如果A是一个3x4x5的矩阵,有B = repmat(A,2,3)则最后的矩阵是6x12x5
例如:
>>B=repmat( [1 2;3 4],2,3)
B =
1 2 1 2 1 2
3 4 3 4 3 4
1 2 1 2 1 2
3 4 3 4 3 4
其结果变为4X6。A也可以置放文字串,如:
>>C=repmat(' Long live the king!', 2,2)
C =
Long live the king! Long live the king!
Long live the king! Long live the king!
也可置放其他的:
>> D=repmat(NaN,2,5)
D =
NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN
matlab isscalar判断是否是一个标量
prod([1:5])
返回120
prod([2 4 6 8])
返回 384
prod([3 4; 4 5]
返回每列元素的乘积 12 , 20
函数名称: isnumeric函数功能: 判断输入参数是否是数字类型(包括浮点型和整型)语法格式:tf = isnumeric(A)返回1(true)如果A是数字类型的, 返回0(false)如果A不是数字类型的.类型的。相关函数:isa、islogical应用举例>> char_arr = 'Hello';>> isnumeric(char_arr)ans =0>> fp_arr = [1.0, 2.1, 3.2];>> isnumeric(fp_arr)ans =1>> integer_arr = int32([1 2 3]);>> isnumeric(integer_arr)ans =1>> bool_ver = ispc;>> isnumeric(bool_ver)ans =0
>>C{1,1} = pi; % doubleC{1,2} = 1; % doubleC{1,3} = ispc; % logicalC{1,4} = magic(3) % double arrayC =[3.1416] [1] [1] [3x3 double]>>for k = 1:4x(k) = islogical(C{1,k});endxx =0 0 1 0示例二:>> A = [true 1 false 0];>> islogical(A)ans = 0>> A = [true true false false];>> islogical(A)ans = 1
- matlab集锦
- C#使用MATLAB集锦
- Matlab问题集锦
- MATLAB中小技巧集锦
- matlab 常用命令集锦
- matlab画图集锦
- matlab函数的集锦
- matlab函数集锦
- matlab知识集锦
- matlab知识集锦
- C#使用Matlab集锦
- Matlab绘图集锦
- matlab 函数集锦
- MATLAB使用集锦一
- matlab 函数集锦
- Matlab常见问题集锦(不断更新)
- Matlab 常用命令集锦---数组操作
- matlab编程笔记:错误集锦
- Android开发优化之——对界面UI的优化(1)
- 敏感词过滤
- Linux下利用backtrace追踪函数调用堆栈以及定位段错误
- linux shell 变量
- 解决Android解析图片的OOM问题!!!
- matlab集锦
- INSERTION-SORT插入排序
- 你既选择了这条路 又何必在意要走多久呢
- UVa 11526 - H(n) [数学]
- Android 日期控件的简单实现
- 单例设计模式
- 祝所有的程序猿春节愉快,好好休息
- Rotate List
- 多媒体卡和SD卡的卡识别过程