help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vectorise for loop in Octave


From: Przemek Klosowski
Subject: Re: vectorise for loop in Octave
Date: Mon, 11 May 2020 19:41:34 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

On 5/11/20 5:41 PM, AURORA GONZALEZ VIDAL wrote:

Hello!


I am trying to vectorise the for loops of a script to make it faster and some of them look like the following:

R = dlmread('Rp.csv');

for m = 1:4
  eval(['node' num2str(m) '= R(m,:);']);
end

Here I am creating the variables node1, node2, node3, node4. But I am not able to do it as follows:

'eval' and creating custom named variables seem to me the opposite to vectorization, which usually leverages Octave's "do this over the entire multidimentional array" operation.

What exactly are you trying to do? Why do you believe that node1 is better than node(1,:)?


clear
R = dlmread('Rp.csv');
eval(['node' num2str(1:4) '= R(1:4,:);']);

Any suggestions on how to vectorise it or make them faster?

Thank you very much for your time
 



---------------

Aurora González Vidal                      Ph.D. in Data Analytics for Energy Efficiency                                  President of Murcia R Users Association (UMUR)
T. +34 868 88 7866                             Department of Information and Communication Engineering                gauss.inf.um.es/umur
address@hidden                  Faculty of Computer Sciences
https://auroragonzalez.github.io/        University of Murcia                                                          &nb sp;                     


    



reply via email to

[Prev in Thread] Current Thread [Next in Thread]