Formatting a vector to not include the first value

조회 수: 6 (최근 30일)
Adil Saeed
Adil Saeed 2022년 8월 14일
댓글: Les Beckham 2022년 8월 16일
RL = [1;2;3;4;5;6;7;8;9;10];
t = 5;
RL = RL + 10*log10(t);
so this is an example of my code, however i do not want the last equation to include the first value from the original vector and i want it to hold that value. so the new RL vector, the first value is 1 and the rest is some new value based on this calculation.

채택된 답변

Les Beckham
Les Beckham 2022년 8월 14일
It seems like you could benefit from taking this introduction to using Matlab: Matlab onramp
This is an example of very basic indexing which you will learn if you go through this simple introduction. to using Matlab.
After you go through that, you will learn that using an index vector allows you to select which elements of a vector are selected.
For your example:
RL = [1;2;3;4;5;6;7;8;9;10];
t = 5;
RL(2:end) = RL(2:end) + 10*log10(t)
RL = 10×1
1.0000 8.9897 9.9897 10.9897 11.9897 12.9897 13.9897 14.9897 15.9897 16.9897
This tells Matlab to only modify the elements of RL from indices 2 through the end of the vector RL.
Please take advantage of the free training. Matlab is very powerful if you take the time to learn to use it.
  댓글 수: 2
Adil Saeed
Adil Saeed 2022년 8월 15일
Much appreciated and thank you for the providing the link to develop my MATLAB skills further
Les Beckham
Les Beckham 2022년 8월 16일
You are quite welcome.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by