g******s 发帖数: 733 | 1 比如要一个 1*3的向量,乘一个3*100的矩阵.
向量的第i个元素乘矩阵的第i行,结果为3*100的矩阵. 请问不用for循环matlab能行吗?` |
g***i 发帖数: 90 | 2 many ways. one:
diag(v)*A
【在 g******s 的大作中提到】 : 比如要一个 1*3的向量,乘一个3*100的矩阵. : 向量的第i个元素乘矩阵的第i行,结果为3*100的矩阵. 请问不用for循环matlab能行吗?`
|
g******s 发帖数: 733 | 3 you are really an expert! Thank you so much!
吗?`
【在 g***i 的大作中提到】 : many ways. one: : diag(v)*A
|
g******s 发帖数: 733 | 4 请问怎样从一个3*100 的矩阵的第 i 行减去一个长度为3的向量的第i个元素? 好象这个
不用循环是不行了.
行
【在 g******s 的大作中提到】 : you are really an expert! Thank you so much! : : 吗?`
|
l*****i 发帖数: 3929 | 5 A=A-diag(v)*ones(size(A))
【在 g******s 的大作中提到】 : 请问怎样从一个3*100 的矩阵的第 i 行减去一个长度为3的向量的第i个元素? 好象这个 : 不用循环是不行了. : : 行
|
r****y 发帖数: 1437 | 6
Let a is your vector, and B is the matrix,
repmat(a', 1, 100) .* B
【在 g******s 的大作中提到】 : 比如要一个 1*3的向量,乘一个3*100的矩阵. : 向量的第i个元素乘矩阵的第i行,结果为3*100的矩阵. 请问不用for循环matlab能行吗?`
|
r****y 发帖数: 1437 | 7
B - repmat(a', 1, 100)
You really need to learn some basic about matlab ah.
【在 g******s 的大作中提到】 : 请问怎样从一个3*100 的矩阵的第 i 行减去一个长度为3的向量的第i个元素? 好象这个 : 不用循环是不行了. : : 行
|
w**d 发帖数: 2334 | 8 why bother? In the new version of Matlab, for loop won't slow your program
down.
【在 g******s 的大作中提到】 : 请问怎样从一个3*100 的矩阵的第 i 行减去一个长度为3的向量的第i个元素? 好象这个 : 不用循环是不行了. : : 行
|
s***t 发帖数: 195 | 9 explain more?
【在 w**d 的大作中提到】 : why bother? In the new version of Matlab, for loop won't slow your program : down.
|
w**d 发帖数: 2334 | 10 i need to dig out my notes. It might be related to the issue of memory.
A senior engineer from mathworks once gave
several lectures on Matlab. He told us so.
【在 s***t 的大作中提到】 : explain more?
|
s***t 发帖数: 195 | 11 as far as i know, the matrix operations in matlab are implemented with BLAS.
plus matlab is an intepreter, not a compiler (i know you can compile matlab
code, but it's another story). these two reasons make it hard to believe
for loops are as fast as matrix operations in matlab.
i would certainly want to know any new development in matlab.
【在 w**d 的大作中提到】 : i need to dig out my notes. It might be related to the issue of memory. : A senior engineer from mathworks once gave : several lectures on Matlab. He told us so.
|
w**d 发帖数: 2334 | 12 i know it is hard to beat BLAS. In my understanding, the for-loop might be not
as effecient as BLAS, but won't be slower than the standard for-loop in C or
Fortran.
But the main reason for the slow speed of for-loop is because during
the for-loop, lots of intermediate variables are generated.
In the new version, it is not done in that way if the matrix variable
has been initialized.
Mathworks has done something to improve the speed. You can go to the website of mathworks, and search with
keywor
【在 s***t 的大作中提到】 : as far as i know, the matrix operations in matlab are implemented with BLAS. : plus matlab is an intepreter, not a compiler (i know you can compile matlab : code, but it's another story). these two reasons make it hard to believe : for loops are as fast as matrix operations in matlab. : i would certainly want to know any new development in matlab.
|
s***t 发帖数: 195 | 13 sorry, just read my post again. it seems i always left some critical words
in my sentences. i meant to say "i would certainly WANT TO know any new
development" :)
anyways, why search for "jitter"? isn't it variation in sampling time? i
searched and didn't see many relavant results. can you give some links?
【在 w**d 的大作中提到】 : i know it is hard to beat BLAS. In my understanding, the for-loop might be not : as effecient as BLAS, but won't be slower than the standard for-loop in C or : Fortran. : But the main reason for the slow speed of for-loop is because during : the for-loop, lots of intermediate variables are generated. : In the new version, it is not done in that way if the matrix variable : has been initialized. : Mathworks has done something to improve the speed. You can go to the website of mathworks, and search with : keywor
|