jeudi 2 mai 2019

MATLAB: Format Character Array Output Back to the Declared Variables

This character array uses a for loop to index through the (basketArray) data, uses IF to check for subscript (‘00’) in data, and if true deletes the (00) subscript. This is achieved with the output of: rmsubscript = applesorangespineapplespinachbroccoliturnips.

Next step is where I am having the problem: how do I get the character array output back into its declared x and y containers, formatted by a column and separated as:

x = apples

oranges

pineapple

y = spinach

broccoli

turnips

Here is my code:

x = ['00apples', 'oranges', '00pineapple']
y = ['00spinach', 'broccoli', '00turnips']

basketArray = [x, y]
pattern = '00';
subscript = contains(basketArray, pattern);
for k = basketArray
    if subscript == contains(basketArray, pattern);
            rmsubscript = regexprep(basketArray, '00', ''),                                                    
    end
end

Aucun commentaire:

Enregistrer un commentaire