Sign in

username:

password:



Not a member?

Search matlab



Search tips

Subscribe to matlab



matlab by Keywords

Atanh | Autocorrelation | Bandpass Filter | C++ | Conv | Database | Deconv | Excel | FFT | Filter | Filtering | FIR | Fourier Transfrom | FSK | Gaussian Noise | Haykin | IFFT | Image | Java | LFSR | LMS | LPC | MEX | OFDM | QPSK | Radix | Random | Sampling | Segmentation | Simulink | Visual Basic | Waveform | Wavelet

Ads

Discussion Groups

Discussion Groups | Matlab DSP | Ignoring whitespaces in a string matrix

Technical discussion about Matlab and issues related to Digital Signal Processing.

  

Post a new Thread

Ignoring whitespaces in a string matrix - bartvandewal - Apr 30 8:19:57 2008



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


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Ignoring whitespaces in a string matrix - arkkimede - May 1 8:37:50 2008

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
>
>  
>



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Ignoring whitespaces in a string matrix - "Raja' S. Alomari" - May 1 8:38:28 2008

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
>



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )