(
Jump to the original submission)
Wed 09 May 2012 06:43:27 AM UTC, comment #9:
This one seems to be fixed. Can this be closed now?
|
Wed 18 May 2011 09:41:49 PM UTC, comment #8:
Matlab has its mysterious ways. Here is the latest:
>> version
ans =
7.9.0.529 (R2009b)
>> ['s1', {[1,1]}]
ans =
's1' [1x2 double]
>> [{[1,1]}, 's1']
ans =
[1x2 double] 's1'
>>
|
Wed 18 May 2011 09:16:07 PM UTC, comment #7:
Well if you want to know the results weren't what I was expecting. Why should all three arguments be promoted to cell strings in the first example, but in the third case only after the two strings are concatenated.. This seems like another case of an adhoc matlab implementation.
In fact I now have another case that might be problematic. What does matlab give for
['s1', {[1,1]}]
[{[1,1]}, 's1']
That is does the promotion of the strings only happen is the cell array contains strings, or does the promotion always happen?
D.
|
Wed 18 May 2011 07:00:35 AM UTC, comment #6:
I will not speculate about what you expected this time:
>> version
ans =
7.9.0.529 (R2009b)
>> ['s1', 's2', {'s3'}]
ans =
's1' 's2' 's3'
>> ['s1'; 's2'; {'s3'}]
ans =
's1'
's2'
's3'
>> ['s1', 's2'; {'s3'}]
ans =
's1s2'
's3'
>>
|
Wed 18 May 2011 06:52:38 AM UTC, comment #5:
Ok its a little harder than I thought because we have to promote the strings to cell strings before checking the dimensions in the concatenation. However this raises another question of how matlab handles these cases
['s1', 's2', {'s3'}]
['s1'; 's2'; {'s3'}]
['s1', 's2'; {'s3'}]
D.
|
Wed 18 May 2011 03:42:42 AM UTC, comment #4:
Okay, it does promote to cell string. I'm used to the Octave output which displays '{'/'}' around the answer when the type is of class cell.
|
Wed 18 May 2011 03:24:39 AM UTC, comment #3:
Apparently not: (same Matlab)
>> s = {'s1'};
>> s = [s; 's2'; 's3']
s =
's1'
's2'
's3'
>> sx = ['sx']
sx =
sx
>> whos
Name Size Bytes Class Attributes
s 3x1 348 cell
sx 1x2 4 char
>> sy = s(2)
sy =
's2'
>> whos
Name Size Bytes Class Attributes
s 3x1 348 cell
sx 1x2 4 char
sy 1x1 116 cell
>>
=================================
This seems a bit odd. Does it help?
|
Tue 17 May 2011 11:30:27 PM UTC, comment #2:
Doesn't the test indicate the reverse? That the cellstr was demoted to an ordinary string and returned in a char array along with the other two strings.
|
Tue 17 May 2011 09:30:38 PM UTC, comment #1:
As you guessed, Matlab says:
>> version
ans =
7.9.0.529 (R2009b)
>> s = {'s1'};
>> s = [s; 's2'; 's3']
s =
's1'
's2'
's3'
>>
|
Tue 17 May 2011 08:30:04 PM UTC, original submission:
While porting some code I ran across the following construct
Octave fails for the above. I no longer have access to matlab and can't easily check that matlab in fact supports the above. But the use of this code in the package I'm porting seems to imply that matlab promotes the strings to cell strings. So if someone could check the above and send the result it would be great.
The fix is relatively trivial with the addition of two concatenation methods in op-cell.cc
D.
|
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach File(s):
Comment:
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found