help-octave
[Top][All Lists]
Advanced

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

Re: How to print the string value using fprintf


From: Nicholas Jankowski
Subject: Re: How to print the string value using fprintf
Date: Wed, 22 Apr 2020 17:19:57 -0400

On Wed, Apr 22, 2020 at 5:00 PM GK19 <address@hidden> wrote:
Thanks! it worked

But do you have any other way of representing it ?



I'm not sure what your real data looks like.  If they are all strings, then if they are the same length you could do a char array:

octave:1> a = ['abc'; 'def'; 'ghi']
a =

abc
def
ghi

octave:2> a(1)
ans = a
octave:3> a(1,:)
ans = abc
octave:4> a(3,:)
ans = ghi

if you need more flexibility, you could use a cell array:

octave:7> a = {'abc'; 'defghi'; 'jklmnop'}
a =
{
  [1,1] = abc
  [2,1] = defghi
  [3,1] = jklmnop
}

octave:8> a{1}
ans = abc
octave:9> a{2}
ans = defghi
octave:10> a{3}
ans = jklmnop

those could then be indexed in a loop.



reply via email to

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