vector not produced missing some '.' ?
조회 수: 1(최근 30일)
Sean de Wolski 2011년 4월 7일
vectorize('g = (0.30/(2*(pi*t^3)^0.5))*exp((-0.30^2)/(4*t))');
A brainless way for us lazies.
Matt Fig 2011년 4월 7일
As a general rule when dealing with operations on arrays, use a dot before every one of the three operators:
* / ^
If you do this you will be fine.
David Young 2011년 4월 7일
If you don't understand the operators, the most straighforward thing is to use
g = (0.30 ./ (2 .* (pi .* t .^ 3) .^ 0.5)) .* exp((-0.30 .^ 2) ./ (4 .* t));
so that all the operators behave as elementwise operators (which I guess is what you want). If you understand the difference, you can omit some of the dots, but they do no harm.
It's not all that hard really: *, / and ^ carry out matrix operations (like matrix multiplication, as defined here), while .*, ./ and .^ operate point by point on the elements of the matrices.