How to replace all row vectors except 1st according to the difference?

3 次查看(过去 30 天)
I have a matrix named as 'two' of size 100 x 4. I have also a singe row vector u=[-55 55 65 -65]; Let we find the error between 1st row of matrix two and u i.e.,
Error=two(1,:)-u;
Now I want to find 99 more Error elements from this single Error which are logrithmically decreasing. Then I want to replace all 99 row vectors of matrix two according to these 99 Errors. The matrix 'two' is in the mat file 4sn0dB.mat which is given in the attachment.
  2 个评论
Kevin Holly
Kevin Holly 2023-1-16
"Then I want to replace all 99 row vectors of matrix two according to these 99 Errors"
How did you want to do this? Do you want to replace row with large error above a specific threshold? What will you replace the row with?
Sadiq Akbar
Sadiq Akbar 2023-1-16
编辑:Sadiq Akbar 2023-1-16
Thanks a lot dear Kevin Holly for your kind response. When I find the 1st Error i.e.,
Error=two(1,:)-u;
Then I want to extend this one Error into 99 such values which are logritmically decreasing values of this Error. Say for example the above 1st Error is Error=[0.001 -0.021 0.0021 0.015]. Now I want o find 99 more Errors from this single Error but those all should be logrithmically decreasing values of this. Then add the corresponding Error2 to u to get two(2,:). Likewise add Error3 to u to get two(3,:) and so on. Likewise for all 99 Errors, add them to u to get all 99 rows of updated two matrix.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2023-1-16
编辑:Matt J 2023-1-16
two = (two(1,:)-u).*logspace(0,-5,100)' +u;
  2 个评论
Sadiq Akbar
Sadiq Akbar 2023-1-16
Thanks a lot dear Matt J for your kind response. I did like below using your code:
clear all; clc
load 4sn0dB
two2 = (two(1,:)-u).*logspace(0,-5,10)' +u;
Both=[two two2]
But it gives me the following error:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in ReplacingMatrix_twoRows (line 7)
Both=[two two2]

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by