Generation of a column with constants values that increases for different RANGE of row

13 次查看(过去 30 天)
I'm trying to generate ONE column of numbers in Matlab as follows:
1) let the value be equal 10 for row 1 to 30,
2) let the value be equal 10 + increment (for example increment=8) for row 31 to 60,
3) let the value increase in increments of 8 for each new sequence of row 1 to 30
until final constant value equals a number, (for example, 82)
I tried a loop like this:
for f =1:30
for g=(10:8:82);
h(f,1) = g;
end;end;
but did not work.
My result is only a column with the constant 82
from row 1 until 30.
I wonder if someone could help me.
Thanks
Emerson

采纳的回答

Oleg Komarov
Oleg Komarov 2011-3-28
1) A( 1:30,1) = 10;
2) A(31:60,1) = 18:8:10+8*30;
3) not clear
  2 个评论
Emerson De Souza
Emerson De Souza 2011-3-28
Dear Oleg
thanks for your answer.
Basically, I want to generate a matrix M of TWO columns and J rows.
An initial value (=XSTART) is fixed for the first column
while the second column runs from a value
YSTART in increments K until a final value YEND .
Then an increment L is added to XSTART
and the second column runs again from
YSTART in increments K until a final value YEND.
The increment L stops if the value of X equals XEND.
For example, let
X runs in increment of 4 from 0 until 12 (XSTART=0, L=4, XEND=8)
The vector components are (0, 4, 8)
Y runs in increment of 5 from 0 until 15 (YSTART=0, K=5, YEND=15)
The vector components are (0, 5, 10, 15)
The resulting matrix should be
0 0
0 5
0 10
0 15
4 0
4 5
4 10
4 15
8 0
8 5
8 10
8 15
I hope this text clarify your doubts
and help you to find the proper sintax two
write a command that generate this matrix for given
set of initial and end values for x and y and their respective increments.
Thank you a lot
Emerson

请先登录,再进行评论。

更多回答(0 个)

类别

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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by