Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Please help me test to see if a string is divisible by a number using tk (token).

1 回表示 (過去 30 日間)
Kevin Smith
Kevin Smith 2017 年 10 月 24 日
編集済み: Kevin Smith 2017 年 10 月 24 日
I am trying to write a script to see if a text file 'example.txt'
67 33 60
-9 6
89 99 66
is divisible by aa given number. I've gotten this script I have been working on:
ifh=fopen(fname,'r'); %open the file for reading
[tk,ln]=strtok(ln);
if mod(tk/num==0)
end
fprintf(ofh, '%s ', tk);
but I'm not sure how to get the test each token to see if it is divisible. I was told the str2num and num2str functions would be useful. I do not fully understand how to use the tk function.
  2 件のコメント
Stephen23
Stephen23 2017 年 10 月 24 日
"but I'm not sure how to get the test each token to see if it is divisible."
I showed you that more than twelve hours ago, in your previousl (almost) identical question. Please do not repeatedly post the same question.
Kevin Smith
Kevin Smith 2017 年 10 月 24 日
編集済み: Kevin Smith 2017 年 10 月 24 日
You did not show me using the token function, that is why I asked this again. Thanks for the help but I can not use the script you provided. The functions you used have not been taught in my class so I cannot use them.

回答 (0 件)

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by