Prev: Slow down mpg-movie
Next: 2d animation in pdf
From: Ruben on 17 Jun 2010 07:28 Hello, I want to replicate a string am wondering if theres a way of creating an array of strings by means of a function. Actually my intention is to get use a function that gets an string and a number n and returns this string replicated n times. For example: res = function ('rand', 3) res = [rand, rand, rand] I have tried using repmat but the result is res = repmat('rand', 1, 3) res = [randrandrand] Maybe the solution is to use cells but is there a function similar to repmat that generate cells? Regards
From: Bruno Luong on 17 Jun 2010 07:40 "Ruben " <ruben(a)heatmail.com> wrote in message <hvd0s4$rma$1(a)fred.mathworks.com>... > Hello, > > I want to replicate a string am wondering if theres a way of creating an array of strings by means of a function. Actually my intention is to get use a function that gets an string and a number n and returns this string replicated n times. For example: > > res = function ('rand', 3) > > res = [rand, rand, rand] > > I have tried using repmat but the result is > > res = repmat('rand', 1, 3) > > res = [randrandrand] > > Maybe the solution is to use cells but is there a function similar to repmat that generate cells? > Because a cell is an array of single cell, you can use REPMAT as well res = repmat({'rand'}, 1, 3) Bruno
From: Ruben on 17 Jun 2010 08:05 Thank you Bruno, It was just in front of my eyes and I couldn't see it !!! Regards "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hvd1j6$ctk$1(a)fred.mathworks.com>... > "Ruben " <ruben(a)heatmail.com> wrote in message <hvd0s4$rma$1(a)fred.mathworks.com>... > > Hello, > > > > I want to replicate a string am wondering if theres a way of creating an array of strings by means of a function. Actually my intention is to get use a function that gets an string and a number n and returns this string replicated n times. For example: > > > > res = function ('rand', 3) > > > > res = [rand, rand, rand] > > > > I have tried using repmat but the result is > > > > res = repmat('rand', 1, 3) > > > > res = [randrandrand] > > > > Maybe the solution is to use cells but is there a function similar to repmat that generate cells? > > > > Because a cell is an array of single cell, you can use REPMAT as well > > res = repmat({'rand'}, 1, 3) > > Bruno
|
Pages: 1 Prev: Slow down mpg-movie Next: 2d animation in pdf |