Question

In matlab, is it possible to fprintf 2 input in one sentence? example: input_1=2/ input_2=5 fprintf('for...

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')

Homework Answers

Answer #1

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
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Regarding fprintf which of the following is true Select one: a. fprintf is one of the...
Regarding fprintf which of the following is true Select one: a. fprintf is one of the most successful ideas introduced by Matlab and its parent company. b. fprintf is a quick and easy way to print matrices if we do not want complicated formatting c. fprintf should never be used and will soon be removed from Matlab. The disp command is what one should use d. The output of fprintf is strictly machine readable e. fprintf is a flexible mechanism...
Code in Matlab. I need to make a diamond shape with * I get part of...
Code in Matlab. I need to make a diamond shape with * I get part of it with the code below. Instructions are: " Given the value of N print diamond of N + (N-1) rows. For example, if N = 5 it should print a diamond." clc clear n = input ('number of rows \n') o = input ('number of inverted rows \n') t = (o-1) for i = 1:n for k = 1:n-i fprintf (' '); end for...
use MATLAB !!!!!1Must answer 2 and 3 together. use MATLAB code only in the simplest term...
use MATLAB !!!!!1Must answer 2 and 3 together. use MATLAB code only in the simplest term 2.Prompt the user to enter an array of numbers. Use the length function to determine how many values were entered, and use disp function to report your results to the command Window. 3.Repeat Exercise 2, and use fprintf to report your results.
C#: Prompt the user to input a sentence. Once you have their sentence, figure out how...
C#: Prompt the user to input a sentence. Once you have their sentence, figure out how many vowels (a, e, i, o, u) and how many consonants are in the sentence. Output the total number of consonants and vowels in the following format (2 separate lines and the format specifier should be general with 0 decimal places!) There were 5 vowels in the sentence. There were 15 consonants in the sentence.
IN MATLAB: Write a function file that takes a vector as an input and returns another...
IN MATLAB: Write a function file that takes a vector as an input and returns another vector with all repeated elements of the original vector. For example, the vector [3 4 1 0 4 -5 7 3] would return the vector [3 4]. Do not use the built-in function "repelem."
In Python Read the following code: alphabet = "abcdefghіjklmnopqrstuvwxyz"   sentence = input(“Type a phrase: “) sentence...
In Python Read the following code: alphabet = "abcdefghіjklmnopqrstuvwxyz"   sentence = input(“Type a phrase: “) sentence = sentence.lower() nοrm_sentence = "" fοr z in sentence:   if letter in alphabet:     norm_sentence += z r_sentence = ““ for number in norm_sentence:    r_sentence ⚌ number += r_sentence if r_sentence == norm_sentence:   print("Yes [] is one".format(sentence)) еlsе:   print("No [] is not".format(sentence)) Fix all syntax and logical codes I am really struggling with this one some help would be great!
Create a MATLAB Function for the half pipe volume problem. inputs length and OD outputs the...
Create a MATLAB Function for the half pipe volume problem. inputs length and OD outputs the volume in gals %half_pipe.m %calculates the volume of the cylinder and converts volume to gallons. %Variables %len=length %od=outer diameter len=input('Enter length of cylinder: '); od=input('Enter outer diameter of cylinder: '); %Calculate id=0.8*od; vol_outer=0.5*pi*(od/2)^2*len; vol_inner=0.5*pi*(id/2)^2*len; %Result vol=vol_outer-vol_inner; v_gals=vol/231; %Output fprintf('The volume of gallons is %1.4f gal \n ',v_gals) Call the function from the command window to run. Example for command window: >>halfpipe_vol = halfpipe_volume_function(10,4) [return...
Matlab: As the user to input 4 quiz grades and 2 test grades. Calculate the final...
Matlab: As the user to input 4 quiz grades and 2 test grades. Calculate the final and letter grade when quizzes are worth 50% of the grade and each test is worth 25% of the grade. Display the final grade to the tenth along with the letter grade.
4. While loops in MATLAB Get a binary from the user by input. And turn it...
4. While loops in MATLAB Get a binary from the user by input. And turn it into the decimal using while loop. (Hint: store the input binary as a character array and perform operation on each element). Finally, check the answer of your script with bin2dec.
how to modify code in matlab to have a calculation linked to various names? for example...
how to modify code in matlab to have a calculation linked to various names? for example if katie weighs 120 lbs and her density is 2.2, but abby weighs 140 lbs and her density is 3.4 the output i want is volume how do i associate weight and density to a name? so if the user were to input “katie” matlab would know that the weight and density are 120 and 2.2
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT