How can I create a new line matrix with specified value for some intervals?

Please, I would like to have just one line with this value:
(1,1:3) = 10; (1,4:7) = 17; (1,8:10) = 15;
Creating a matrix = [10 10 10 17 17 17 17 15 15 15], but in my case one M(1x26530).
Thank you very much Fernando

 Accepted Answer

[10*ones(1,3) 17*ones(1,7-4+1) 15*ones(1,10-8+1)]

3 Comments

Thank you Azzi, but one error when...
EDU>> [10*ones(1,1:3) 17*ones(1,4:7) 15*ones(1,8:10)] Warning: Size inputs must be scalar. This will error in a future release.
ans =
10 17 17 17 17 15 15 15 15 15 15 15 15

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!