lundi 30 mars 2015

how to replace a string in a cell with multi row character in matlab

i am using a template and regexprep to replace character. my template is huge so i can't post it here. so consider that my template name is templateGetC. I use



regexprep(templateGetC,'<final_bus_name>',component_name);


to replace the 'final_bus_name' in my template with the component_name which has the value 'machine'. but what if i want to replace it with a multi row string. like if



a= ' start the experiment
analyse the content
end the experiment'


and if i want to replace 'final_bus_name' with 'a' it throws me an error that 'The third argument (REPLACE) must be a one-dimensional array of char or cell arrays of strings.'


is there any other way to replace it. i tried num2cell but it's horrible and just messes up the data.


i also tried strrep but it throws the error 'Input strings must have one row.'


Aucun commentaire:

Enregistrer un commentaire