help-octave
[Top][All Lists]
Advanced

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

Re: Passing the values in a fixed format


From: Nicholas Jankowski
Subject: Re: Passing the values in a fixed format
Date: Wed, 24 Jun 2020 13:42:43 -0400

On Wed, Jun 24, 2020 at 1:17 PM Ganesh Kini <ganeshrkini19@gmail.com> wrote:
I have 2 arrays

Position = {"ITC""VTC""KZT"};

Direction = [0.34 0.56 0.99]


I have a pass these values to a interpn function such a way it should pass as set of values, which means i should pass like Position = "ITC" and direction = 0.34 , during the next position = "VTC" and direction = 0.56 and the last one. how do i do that  ?


so it seems you want to pass all of the first ones, process them, then all of the second ones, process them, etc., up until the end of the list.  You can pass them by index.  Recommend reading the following on how to work with arrays and subsets by indexing:

https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html  
https://octave.org/doc/v5.2.0/Index-Expressions.html#Index-Expressions 
https://octave.org/doc/v5.2.0/Advanced-Indexing.html#Advanced-Indexing

specifically to your question:

>> Position = {"ITC","VTC","KZT"}

Position =
{
  [1,1] = ITC
  [1,2] = VTC
  [1,3] = KZT
}

>> Direction = [0.34 0.56 0.99]

Direction =

   0.34000   0.56000   0.99000

>> Position(2)

ans =
{
  [1,1] = VTC
}

>> class(Position(2))

ans = cell
>> Position{2}

ans = VTC
>> class(Position{2})

ans = char
>> Direction(2)

ans =  0.56000


working with a for loop (just printing them to the screen, you can do whatever you want with them):

>> for idx = 1:numel(Direction)
  printf("%s %f\n",Position{idx},Direction(idx));
endfor

ITC 0.340000
VTC 0.560000
KZT 0.990000



reply via email to

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