Dividing each value in a matrix row by a value in the corresponding row of a vector
1 次查看(过去 30 天)
显示 更早的评论
Hi,
Please excuse me if this is difficult to understand - I am new to Matlab and coding in general.
I have a 3x1 vector and a 3x3 matrix. I would like to solve an equation using each value in each row of the matrix, but the equation also requires using the corresponding row value in the vector. For instance, I need to get three solutions using the three values in first row of the matrix while using the value (1,1) in the vector, then get three solutions in the second row using the value (2,1) in the vector and so on.
The equation (which may be coded wrong depending on the answer) is:
Sigma = sqrt(log(1+(Y/Z(i))^2));
For example, if I have vector Y = [1;2;3] and matrix Z = [2 4 6; 8 10 12; 14 16 18] I want to the solutions to:
Sigma = sqrt(log(1+(1)/2)^2)); Sigma = sqrt(log(1+(1)/4)^2)); Sigma = sqrt(log(1+(1)/6)^2));
and
Sigma = sqrt(log(1+(2)/8)^2)); Sigma = sqrt(log(1+(2)/10)^2)); Sigma = sqrt(log(1+(2)/12)^2));
and so on.
Ideally, I would like to do this in a single step, for example using a loop that would give me all the answers in a new matrix. However, I have not been successful after trying many different approaches. Other solutions also welcome, of course. Any advice is much apprciated.
Thanks, Charles
1 个评论
Matt J
2013-3-10
Is i=sqrt(-1) in this context? Also, in
Sigma = sqrt(log(1+(1)/2(i))^2));
does 2(i) mean that both 2 and i are in the denominator?
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!