In matlab, is it possible to fprintf 2 input in one sentence?
example: input_1=2/ input_2=5
fprintf('for input_1 and input_2, the answer is bla-bla-bla')
Ans :
Yes it is possible to output two values in a single sentence in Matlab.
Eg :
input_1=2;
input_2=5;
%fprintf to print a single sentence
fprintf('for %d and %d, the answer is bla-bla-bla')
Here it will result in the following output :
for 2 and 5, the answer is bla-bla-bla
Similarly, you can print multiple values in a single line using fprintf in Matlab.
Another Eg :
w=1;
x=2;
y=3;
z=4;
%fprintf to print a single sentence
fprintf('z with value %d beats y with value %d beats x with value %d beats w with value %d')
Output will be :
z with value 4 beats y with value 3 beats x with value 2 beats w with value 1
Get Answers For Free
Most questions answered within 1 hours.