Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Working with char arrays

  1. Jan 8, 2009 #1
    Hi there!

    I'm having problems with creating/using char arrays.

    My actual code is: (I reduced the options to make it smaller here..)
    Code (Text):

    int option;
    int i;
    fs=11025;  %frequency

    %load wave files into matlab vectors
    [jose]=wavread('jose.wav');
    [antonio]=wavread('antonio.wav');

    [B]nomes=char();   % ????[/B]

    option=0;
    i=0;
    while option~=12
       
        clc;
        disp('1-Jose');
        disp('2-Antonio');
        option=input('Quais os nomes que pretende reproduzir?');
       
        i=i+1;   %I do this to guarantee that we are in the first array position on the first option choosed
       
        switch option
           
            case 1
                nome=[jose];
                [B]nomes(i)=nome;    %  ????[/B]
                i=i+1;
       
            case 2
                nome=[antonio];    
                i=i+1;
           
            case 3
       
            %etc, etc...
           
        end;
       
       
      sound(nomes,fs);  
       
    end;    
    ok, so basicly the funtion sound will play the wav's I want.
    For example, if I want to play antonio.wav and then jose.wav I would do:
    Code (Text):
    sound(antonio, jose, fs)
    And this is when the array appears..
    My idea is to have an array and every option that is choosed will create a new position in that array with the value, for example jose or antonio.
    I'm not getting this to work with this code.. Array problems?

    Help please..


    Thanks in advance.
    Rui.
     
  2. jcsd
  3. Jan 8, 2009 #2

    DaveC426913

    User Avatar
    Gold Member

    We can't debug it if there isn't a bug...

    How is it not working?
     
  4. Jan 9, 2009 #3
    Code (Text):
    Warning: Out of range or non-integer values truncated during conversion to character.
    > In tp3 at 54
      In run at 62
    ??? Error using ==> run
    Subscripted assignment dimension mismatch.
     

    My line 54 in tp3.m is:
    Code (Text):
    nome=[jose];
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Working with char arrays
  1. The Reverse Of 'char' (Replies: 1)

Loading...