[Scilab-users] inserting data into a bigger matrix

Rafael Guerra jrafaelbguerra at hotmail.com
Wed Oct 12 14:45:08 CEST 2016


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-bounces at 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 at 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





--
In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.

There we have the salad.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161012/32ae196b/attachment.htm>


More information about the users mailing list