[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Filling the gaps in data arrays
From: |
Mat086 |
Subject: |
Re: Filling the gaps in data arrays |
Date: |
Thu, 12 Jul 2018 01:36:53 -0700 (MST) |
Doug Stewart-4 wrote
> On Wed, Jul 11, 2018 at 10:37 AM, Mat086 <
> m.gaboardi86@
> > wrote:
>
> Here is one wah to do it;
>
>
>
>
> x = [1 2 3 4 5 6 7 8 9 27 28 29 30 31 32 33 34 35 56 57 58 59 60 61 62 63
> 64 ]
> y = [0.1 0.5 1 5 25 5 1 0.5 .1 0.3 0.5 1.5 15 44 15 1.5 0.5 .3 0.3 0.2 3 9
> 23 9 3 0.2 .3 ]
>
> xx(64)=0
> for k=1:27
> xx(x(k))=y((k));
> endfor
> plot(xx)
> xx
>
>
>
>
>
> --
> DAS
>
> <https://linuxcounter.net/user/206392.html>
Hi and thanks!
This actually works fine only in this particular situation but it doesn't if
you have a non integer x-array like:
x = [1.1:.1:1.9 2.7:.1:3.5 5.6:.1:6.4 ];
y = [0.1 0.5 1 5 25 5 1 0.5 .1 0.3 0.5 1.5 15 44 15 1.5 0.5 .3 0.3
0.2 3 9 23 9 3 0.2 .3 ];
However, I got the hint from you and I modified the script into:
dx = x(2)-x(1);
Y = zeros(1,length([min(x):dx:max(x)]));
X = [min(x):dx:max(x)];
for k=1:length(x)
indx = find(X==x(k));
Y(k) = y(index);
endfor
plot(x,y,'b-'); hold on; plot(X,Y,'-o');
On the best of my knowledge, this should be working fine in Matlab, but with
octave I get the following error as soon as k=3:
......
index = 1
index = 2
index = [](1x0)
error: test_00: =: nonconformant arguments (op1 is 1x1, op2 is 1x0)
......
Any idea?
Many thanks,
Matt
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html