MATALB大坑——".*" "./" "/" "*"

1、要点——带点的都是针对矩阵运算的,如果在矩阵运算时没有注意就会报错

1 ./点除 
对于矩阵,a./b是对应的每个元素相除,得到一个新的矩阵;
2 /1/a代表a的逆,对于数来讲.//没有区别


1. .*点乘,矩阵间对应元素的相乘,
2 '*'运算符用于一般数学意义下的相乘运算。

2、比如下面求积分的这个例子

fun = @(x)(2*x + 1) /sqrt(x .* (1 - x)); %这里的除如果写成了/,就会疯狂报错
q = integral(fun,0,1)

>>>
Error using integralCalc/finalInputChecks (line 526)
Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the
'ArrayValued' option to true.
fun = @(x)(2*x + 1) ./sqrt(x .* (1 - x));
q = integral(fun,0,1)

>> Test9_integral

q =

    6.2832
发布了70 篇原创文章 · 获赞 5 · 访问量 3509

猜你喜欢

转载自blog.csdn.net/qq_42647903/article/details/103388251