[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: line continuations
From: |
José Abílio Matos |
Subject: |
Re: line continuations |
Date: |
Thu, 20 Feb 2020 14:30:55 +0000 |
On Wednesday, 19 February 2020 20.01.12 WET Nicholas Jankowski wrote:
> I think the strrep function is fine. c is a char array. the bug about how
> the array is stored is changing the shape of the array. the substitution
> appears to be fine, if c was actually what you wanted (a two row char
> array). As stated in 'help char', Matlab/Octave concatenates char arrays
> vertically (are stored columnwise). so the stored order is 1 4 2 5 3 6. eg:
>
> octave:13> a=char('test1','test2')
> a =
>
> test1
> test2
>
> octave:14> a(1)
> ans = t
> octave:15> a(2)
> ans = t
> octave:16> a(:)
> ans =
>
> t
> t
> e
> e
> s
> s
> t
> t
> 1
> 2
I am aware of this as well of the other variant:
>> a(1:end)
ans = tteesstt12
What I was trying to understand is if this result is an expected outcome or if
it would be better to throw an error in this scenario (just like Matlab does).
The matrix of char is confusing and probably (and this is the degree of
certainty that I am trying to determine) the user wanted instead to use the
cell array version:
>> a = {'test1';'test2'}
>> strrep(a, 't', '-')
ans =
{
[1,1] = -es-1
[2,1] = -es-2
}
and this works the same in Octave and Matlab.
Regards,
--
José Matos
- Re: line continuations, Rik, 2020/02/19
- Re: line continuations, José Abílio Matos, 2020/02/19
- Re: line continuations, Nicholas Jankowski, 2020/02/19
- Re: line continuations,
José Abílio Matos <=
- Re: line continuations, Nicholas Jankowski, 2020/02/20
- Re: line continuations, José Abílio Matos, 2020/02/20
- Re: line continuations, Nicholas Jankowski, 2020/02/20
- Re: line continuations, José Abílio Matos, 2020/02/20
- Re: line continuations, Nicholas Jankowski, 2020/02/20
- Re: line continuations, José Abílio Matos, 2020/02/20