Re: [Scilab-users] Shift indices
Dear, this instruction is exactly the one I wanted It allows me on a PELTON 6 jet machine to get a rotating pilot injector Pierre. De : users [mailto:users-boun...@lists.scilab.org] De la part de Samuel Gougeon Envoyé : jeudi 9 novembre 2017 00:31 À : Users mailing list for Scilab Objet : Re: [Scilab-users] Shift indices Le 08/11/2017 à 15:07, Richard llom a écrit : Hello, is there a function available to shift indices? E.g. I have aa = [1:10] and want bb = 6. 7. 8. 9. 10. 1. 2. 3. 4. 5. If you need to shift i = 1:n indices by any p -- not necessarily n/2 --, you may do si = modulo(i+p-1, n)+1// with n = length(i); Example: i = 1:10, p = 2; si = modulo(i+p-1, length(i))+1 --> i = 1:10, p = 2; i = 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. --> si = modulo(i+p-1, length(i))+1 si = 3. 4. 5. 6. 7. 8. 9. 10. 1. 2. Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
Thank you all for the replies! This is my solution now: // Wrap around at June 1st ix1 = find(log_date==datenum(log_data(1,3),06,01)) ix2 = [ix1+1:size(log_data,1),1:ix1]; dat2 = log_data(ix2,6); (which is much easier to read :-) -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
Yes we can, with the one liner solution: log_data = [log_data(4001:$, :); log_data(1:4000, :)]; Rafael -Original Message- From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Samuel Gougeon Sent: Thursday, November 09, 2017 2:05 PM To: Users mailing list for Scilab Subject: Re: [Scilab-users] Shift indices Le 09/11/2017 à 12:42, Rafael Guerra a écrit : > n = size(log_data,1); > log_data = log_data([4001:n,1:4000], :); Yes, it's definitely simpler! (unfortunately, we can't use the implicit polynomial 4001:$ to replace n=.., 4001:n, because it can't be concatenated) ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
Le 09/11/2017 à 12:42, Rafael Guerra a écrit : n = size(log_data,1); log_data = log_data([4001:n,1:4000], :); Yes, it's definitely simpler! (unfortunately, we can't use the implicit polynomial 4001:$ to replace n=.., 4001:n, because it can't be concatenated) ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
n = size(log_data,1); log_data = log_data([4001:n,1:4000], :); Rafael -Original Message- From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Samuel Gougeon Sent: Thursday, November 09, 2017 12:06 PM To: Users mailing list for Scilab Subject: Re: [Scilab-users] Shift indices Le 08/11/2017 à 15:07, Richard llom a écrit : > Hello, > is there a function available to shift indices? > E.g. I have > aa = [1:10] > and want > bb = 6. 7. 8. 9. 10. 1. 2. 3. 4. 5. > > This is what I come up with: > log_data2 = zeros(log_data); > log_data2 = log_data(4001:size(log_data,1),:); > log_data2((size(log_data,1)-4000+1):size(log_data,1),:) = > log_data(1:4000,:); > > But I'm wondering if there is a prettier solution? n = size(log_data,1); log_data = log_data(modulo((1:n)-2+4001, n)+1, :); Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
Le 08/11/2017 à 15:07, Richard llom a écrit : Hello, is there a function available to shift indices? E.g. I have aa = [1:10] and want bb = 6. 7. 8. 9. 10. 1. 2. 3. 4. 5. This is what I come up with: log_data2 = zeros(log_data); log_data2 = log_data(4001:size(log_data,1),:); log_data2((size(log_data,1)-4000+1):size(log_data,1),:) = log_data(1:4000,:); But I'm wondering if there is a prettier solution? n = size(log_data,1); log_data = log_data(modulo((1:n)-2+4001, n)+1, :); Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
Le 08/11/2017 à 15:07, Richard llom a écrit : Hello, is there a function available to shift indices? E.g. I have aa = [1:10] and want bb = 6. 7. 8. 9. 10. 1. 2. 3. 4. 5. If you need to shift i = 1:n indices by /any/ p -- not necessarily n/2 --, you may do si = modulo(i+p-1, n)+1// with n = length(i); Example: i = 1:10, p = 2; si = modulo(i+p-1, length(i))+1 --> i = 1:10, p = 2; i = 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. --> si = modulo(i+p-1, length(i))+1 si = 3. 4. 5. 6. 7. 8. 9. 10. 1. 2. Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
Is this solution fine with you? aa = [1:10]; ix = [6:10,1:5]; bb = aa(ix) Regards, Rafael -Original Message- From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Richard llom Sent: Wednesday, November 08, 2017 3:08 PM To: users@lists.scilab.org Subject: [Scilab-users] Shift indices Hello, is there a function available to shift indices? E.g. I have aa = [1:10] and want bb = 6. 7. 8. 9. 10. 1. 2. 3. 4. 5. This is what I come up with: log_data2 = zeros(log_data); log_data2 = log_data(4001:size(log_data,1),:); log_data2((size(log_data,1)-4000+1):size(log_data,1),:) = log_data(1:4000,:); But I'm wondering if there is a prettier solution? Thanks richard -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Shift indices
See fftshift -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users