Technical discussion about Matlab and issues related to Digital Signal Processing.
Hello all,
I'm using a string matrix to generate labels in plots. However, I have
a problem with white spaces. Because the text within the matrix is of
different size, it will also print the white spaces. Is there a way to
solve this problem? To clarify, some code:
coefficientname = char({'aa' 'bbbbbb' 'ccc' 'd'});
for j = 1:length(coefficient)
plot(x(j,:),y(j,:))
xlabel(sprintf('%s [-]',coefficientname(j,:)))
end
Thanks in advance!
Bart
I think that str2mat is the answer.
See a little game with the magic word "abracadabra"
abracadabra =
str2mat('a','ab','abr','abra','abrac','abraca','abracad','abracada','abracadab','abracadabr','a
bracadabra');
BR
On Tue, Apr 29, 2008 at 7:57 PM, bartvandewal <b...@yahoo.com>
wrote:
> Hello all,
>
> I'm using a string matrix to generate labels in plots. However, I have
> a problem with white spaces. Because the text within the matrix is of
> different size, it will also print the white spaces. Is there a way to
> solve this problem? To clarify, some code:
>
> coefficientname = char({'aa' 'bbbbbb' 'ccc' 'd'});
>
> for j = 1:length(coefficient)
> plot(x(j,:),y(j,:))
> xlabel(sprintf('%s [-]',coefficientname(j,:)))
> end
>
> Thanks in advance!
>
> Bart
>
>
>
Hi,
So many different solutions. The best way I like for representing such a
matrix is the cell and you can change back into string at any point by
"strcat." So, in your code, define the matrix as (you can write
coefficientname on command prompt and see how it looks like):
coefficientname = {'aa' 'bbbbbb' 'ccc' 'd'};
Then for the xlabel(strcat(coefficientname(1,j) ))
Hope this helps,
Best regards,
Raja'
On Tue, Apr 29, 2008 at 2:57 PM, bartvandewal <b...@yahoo.com>
wrote:
> Hello all,
>
> I'm using a string matrix to generate labels in plots. However, I have
> a problem with white spaces. Because the text within the matrix is of
> different size, it will also print the white spaces. Is there a way to
> solve this problem? To clarify, some code:
>
> coefficientname = char({'aa' 'bbbbbb' 'ccc' 'd'});
>
> for j = 1:length(coefficient)
> plot(x(j,:),y(j,:))
> xlabel(sprintf('%s [-]',coefficientname(j,:)))
> end
>
> Thanks in advance!
>
> Bart
>