[Scilab-users] Padarray Matlab equivalent in Scilab
Lester Anderson
arctica1963 at gmail.com
Thu Feb 11 10:32:38 CET 2016
Thanks for the update Samuel. Got the padding working as you suggested:
clear()
data = [1 2 3; 4 5 6; 7 8 9]
addedRows = 3; addedCols = 3;
tmp = [data ; data($, :) .*. ones(addedRows, 1)];
tmp = [tmp tmp(:, $) .*. ones(1,addedCols)];
tmp = [repmat(tmp(1, : ), addedRows, 1) ; tmp];
paddedMat = [repmat(tmp(:,1) , 1, addedCols) tmp]
Perhaps an equivalent to "padarray" could be built into the next version(s).
On 10 February 2016 at 19:00, Samuel Gougeon <sgougeon at free.fr> wrote:
> Le 10/02/2016 16:43, sgougeon at free.fr a écrit :
>>>
>>> Thanks for the ideas, it kind of solves the need, but pads to left and
>>> bottom only:
>>
>> tmp = [data ; repmat(data($, :), addedRows, 1)];
>> paddedMat = [tmp repmat(tmp(:, $) , 1, addedCols)]
>>
>> padds on the bottom and RIGHT.
>> To pad on the left and top, just tune the concatenation:
>>
>> tmp = [repmat(data($, :), addedRows, 1) ; data];
>> paddedMat = [repmat(tmp(:, $) , 1, addedCols) tmp]
>
> Rather
>
> tmp = [repmat(data(1, : ), addedRows, 1) ; data];
> paddedMat = [repmat(tmp(:,1) , 1, addedCols) tmp]
>
>
> SG
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
More information about the users
mailing list