how do i save and load this file into a human readable format(asked by question)

4 views (last 30 days)
x = input(' Enter any integer in the range betwwen 0 to 255,x:');
if (x<0)
disp('-1')
elseif (x>255)
disp('error.Value too big')
else
fprintf('<%d>\n',x)
end
disp('mcheck');
save mcheck.m;
clear all;
load mcheck.m;
  3 Comments
ernest
ernest on 27 Nov 2014
sorry for the late reply. this is the question i am attempting.maybe it could help you understand what it needs..."4. Write a script, which first asks the user to input an integer number between 0 and 255, then outputs the number to the screen between the characters '<' and '>', and calls an user function ‘mcheck’ (as described below) to check the number entered. The input, display and check operation should be repeated for 10 times. After the 10th iteration, the script should save all the input numbers to a text file in a human readable format. The user function ‘mcheck’ mentioned above will do the following check for each number entered: if the number is in the range of 0~255, no change is needed; if the number entered is bigger than 255, the script should print a message “error: Value too big.” to the screen, but make no change to the value of the number; if a negative number is entered, no matter what is the exact number, the script should convert it to . "
Geoff Hayes
Geoff Hayes on 27 Nov 2014
First, update your above code to iterate the ten times and collect the user input into an array. Once you have done that, and applied mcheck to each input, then write the array to file.

Sign in to comment.

Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!