# Re: [Scilab-users] inserting data into a bigger matrix

```charming...exactly what I need.

2016-10-12 14:45 GMT+02:00 Rafael Guerra <jrafaelbgue...@hotmail.com>:```
```
> Hi Philipp,
>
>
>
> Does the simple code here below meet the requirements?
>
>
>
> I = [0,0,0,1; 10, 0, 3, 1;15, 30, 0, 1;18, 0, 45, 0;36, 57, 28, 0];
>
> ix1=I(1,1);
>
> ix2=I(\$,1);
>
> ix=ix1:ix2;
>
> M=zeros(length(ix),4);
>
> M(1:\$,1) = ix';
>
> M(I(:,1)+1,:)=I;
>
>
>
> PS:
>
> It should be easy to adapt it for a general time series consisting of
> floats and constant time-sampling.
>
>
>
> Regards,
>
> Rafael
>
>
>
> *From:* users [mailto:users-boun...@lists.scilab.org] *On Behalf Of *Philipp
> Mühlmann
> *Sent:* Wednesday, October 12, 2016 2:16 PM
> *To:* International users mailing list for Scilab. <users@lists.scilab.org
> >
> *Subject:* [Scilab-users] inserting data into a bigger matrix
>
>
>
> Dear Scialb users,
>
>
>
>
>
> how to insert time based data into a pre-defined Matrix without using a
> for-loop?
>
>
>
> The data points are not equally spaced in time.
>
>
>
>
>
> example:
>
> // assuming DATA includes 5 data Points
>
> // each dat Point consists of 4 variable
>
> // first variable = time
>
>
>
> //datafile could look like
>
>
>
> Time, Var1, Var2, Var3
>
> 0, 0, 0, 1
>
> 10, 0, 3, 1
>
> 15, 30, 0, 1
>
> 18, 0, 45, 0
>
> 36, 57, 28, 0
>
>
>
> Assume that a timestep of 1 second is wanted.
>
>
>
> desired result should look like this:
>
>
>
> M =
>
> 0 0 0 1
>
> 1 0 0 0
>
> 2 0 0 0
>
> 3 0 0 0.
>
> ...
>
> 10 0 3 1
>
> ...
>
> 15 30 0 1
>
> ...
>
> 18 0 45 0
>
> ...
>
> 36 57 28 0
>
>
>
> so "M" is bigger than the original dataset.
>
>
>
> Again, I think I could do this using for-loops.
>
> This could be OK for small dataset, but maybe become slow for huge data
> sets (> 100'000 data points).
>
>
>
> Thanks,
>
> Philipp
>
>
>
>
>
>
>
>
>
> Thanks,
>
> Philipp
>
>
>
>
>
>
>
>
>
> --
>
>
>
>
> There we have the salad.
>
> _______________________________________________
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>

--
```_______________________________________________