expression

Sujaya Neupane's Avatar

Sujaya Neupane

15 Oct, 2018 08:12 PM

Hi Chris,

Is there a 'matlab' way to do this in mworks:

var curridx = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]

matlab way would be:

var cuuidx = [zeros(5,1) 1*ones(5,1) 2*ones(5,1)....and so on]

I need to create a variable curridx that goes till 11 instead of 5. So, 11 reps of each integer from 0 to 11 in one array.

Thanks!

--
Sujay

  1. Support Staff 1 Posted by Christopher Sta... on 15 Oct, 2018 08:15 PM

    Christopher Stawarz's Avatar

    Hi Sujay,

    Not really. With the currently nightly build, you could use

    [0]*5 + [1]*5 + [2]*5 + [3]*5 + [4]*5 + [5]*5
    

    but I think that's as close as you can get with a single expression.

    Chris

  2. Christopher Stawarz closed this discussion on 19 Oct, 2018 01:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac