Solving an Equation Using a Formula with an Increasing Level of Values

조회 수: 1 (최근 30일)
Lev Mihailov
Lev Mihailov 2022년 2월 21일
댓글: Walter Roberson 2022년 2월 21일
There is a matrix, for each section you need to add a value, how can this be done?
v = [1 2 3 4] ;
iwant = repmat(v,6,1)
% formula v+0.5*cos(7)/pi % presented without multiplication by cosine and division by pi
iwant = 6×4
1.5 2.5 3.5 4.5
2 3 4 5
2.5 3.5 4.5 5.5
3 4 5 6
3.5 4.5 5.5 6.5
4 5 6 7

답변 (1개)

Walter Roberson
Walter Roberson 2022년 2월 21일
v = [1 2 3 4] ;
iwant = repmat(v,6,1);
iwant + (1:6).'/2
ans = 6×4
1.5000 2.5000 3.5000 4.5000 2.0000 3.0000 4.0000 5.0000 2.5000 3.5000 4.5000 5.5000 3.0000 4.0000 5.0000 6.0000 3.5000 4.5000 5.5000 6.5000 4.0000 5.0000 6.0000 7.0000
  댓글 수: 2
Lev Mihailov
Lev Mihailov 2022년 2월 21일
I don't understand why we divide by 2?
Walter Roberson
Walter Roberson 2022년 2월 21일
We want to add 1/2 to the first row, 2/2 to the second row, 3/2 to the third row...

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

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by