Write a script that creates a cell array of strings, each of which is a two-word phrase. The script is to write the first word of each phrase to a file “exitstrings.dat” in the format shown below
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:9| Question number:25.9
All Answers
total answers (1)
Ch9Ex25.m
strca = {'hi there', 'hello all', 'I did'};
outfid = fopen('exitstrings.dat','w');
for i = 1:length(strca)
[f r] = strtok(strca{i});
fprintf(outfid, 'Word %d: %s\n', i, f);
end
fclose(outfid);
need an explanation for this answer? contact us directly to get an explanation for this answer