adding an array with steps untli the last row
이전 댓글 표시
Hello,
How is it possible to create an Array that starts at 0.02 and Ends at the last row of a second Array like 5x1? For example:
a=round(5,1)
a=
5
1
2
4
5
Now I want a second array with the same ammount of rows but starts with 0.02 and adds 0.02 every row like 0.02 0.04 0.06 and so on until the last row of the other array...
If I choose size the Array Counts until the last number of the other Array is reached... please help me!
답변 (3개)
newarray = 0.02 * reshape(1:numel(a), size(a))
would work and produce an array/matrix the same shape of A, regardless of that shape.
댓글 수: 3
tarek rahmani
2017년 3월 17일
correction: ('numel' not 'nume')
newarray = 0.02 * reshape(1:numel(a), size(a))
Guillaume
2017년 3월 17일
Yes, thanks for noticing.
tarek rahmani
2017년 3월 17일
a=[min:step:max]
for ex:
>> a=[1:0.2:2]
a =
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!