Extraction of elements of the array from the function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Extraction of elements of the array from the function

GK19
This post was updated on .
a = (1,3,4,6,8,9,0,5,4,)
b = (3)
c = (4,56,7,8,5,1)
a, b,c are saved in .vec extension
for t1 =1:1:length(a)
        for t2=1:1:length(b)
        for  t3=1:1:length(c)
                period_fun(a,b,c)=time(p);
                p=p+1;
        end
        end
        end
So this code will give me the time
 period fun(5,1,3) which means it will fetch
5th element of a = 8, 1st element of b = 3, 3rd element of c = 7, and the
output is time = 1.1
Now just by looking the output time 1.1 i want to extract the 5th element of
a or the 1st element of b or  3rd element of c and get that element as
output
is it possible ?



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Extraction of elements of the array from the function

nrjank
Administrator
On Sun, Apr 5, 2020 at 12:21 PM GK19 <[hidden email]> wrote:
a = (1,3,4,6,8,9,0,5,4,)
b = (3)
c = (4,56,7,8,5,1)
a, b,c are saved in .vec extension     
for t1 =1:1:length(a)
        for t2=1:1:length(b)
        for  t3=1:1:length(c)
                period_fun(a,b,c)=time(p);
                p=p+1;
        end
        end
        end
So this code will give me the time
 period fun(5,1,3) which means it will fetch
5th element of a = 8, 1st element of b = 1, 3rd element of c = 7, and the
output is time = 1.1
Now just by looking the output time 1.1 i want to extract the 5th element of
a or the 1st element of b or  3rd element of c and get that element as
output
is it possible ?

I'm still not clear on what you're actually trying to do. 

what is p?

is the time function just the octave built-in function time()? I don't think that can take an input. Or is there some other function/variable you've left out of this description?

and period_fun is just a 3-dimensional array of ... the time the iteration occurred?

The pseudocode above obviously wouldn't run in Octave. What have you actually tried to run in octave, and what has/hasn't worked?  It's hard for us to help when you're only providing part of the information.  

What exact information are you starting with (everything), and what exactly would you like as an output?