|
Hello,
I am a teaching assistant for an engineering class, and one of my students submitted an assignment that contains fprintf() statements that are slightly different than what I am accustomed to seeing.
The students were to add '2' to every value in a file 'voltageout.txt'
clc
clear all
%prompt user for filename
fprintf ('What is the filename?\n');
filename = input('filename = ','s');
%store data in file as vector 'voltages'
voltages = load(filename);
%prompt user for offset voltage
offset=input('Enter the offset voltage:\n');
%add offset to voltages
voltages = voltages + 2;
%save data in voltageoutplus2b.txt
save voltageoutplus2b.txt voltages -ascii
fprintf (1,'data has been saved to voltageoutplus2a.txt\n');
the part of this code that was unfamiliar to me was the '1' in the fprintf() statement. I am aware that that position is used for a file identifier; is there any other reason to put a '1' in that position? I also experimented a bit and found that if I replace the '1' with a '2', the string still displays to the command window, but is the color red. Thanks for the assistance!
|