필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Can anyone help with my function?

조회 수: 1 (최근 30일)
Brian Leon
Brian Leon 2020년 4월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
I have this function that is suppose to create a report for a specific story, but it keeps giving me an error when I try to run the function in the command window. Can anyone lead me in the right direction as to what im doing wrong?
function generateReport(storyTitle, numUniqueWords, topTenWords)
% uses the word data to create a report for specific story
% Input: numUniqueWords - integer for the number of unique words in the
% story being analysed
% topTenWords - a 1x10 structure Array of the most frequent words
% Output: a report stored in a .txt file called storyReport.txt
fid = fopen('StoryReport.txt', 'w'); % used to open/load report
fprintf(fid, 'Story Analyzed: %s\n',storyTitle);
fprintf(fid, 'Total Unique Words: %f\n', numUniqueWords);
fprintf(fid, 'Frequency, Word\n');
for i = 1:10
fprintf(fid, '%f, %s\n', topTenWords.frequency{i}, topTenWords.word{1});
end
fclose('storyReport.txt');

답변 (1개)

Walter Roberson
Walter Roberson 2020년 4월 15일
for i = 1:10
fprintf(fid, '%f, %s\n', topTenWords(i).frequency, topTenWords(i).word);
end
  댓글 수: 1
Brian Leon
Brian Leon 2020년 4월 15일
I implemented this to my code and then I got this error.

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by