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

조회 수: 2 (최근 30일)
Sadiq Akbar
Sadiq Akbar 2023년 1월 16일
댓글: Matt J 2023년 1월 16일
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]
Matt J
Matt J 2023년 1월 16일
Should be logspace(0,-5,100)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by