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
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...
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."
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.
Write a function custom sort(v) that takes as input a vector v and as output returns...
Write a function custom sort(v) that takes as input a vector v and as output returns the vector w sorted into increasing order. For example, if the input is [−2 1 3 1 5], the output should be [−2 1 1 3 5]. Don’t use the built-in ”sort” function or anything similar. matlab question
Define a function called positivity generator. The function should take user input of a sentence, and...
Define a function called positivity generator. The function should take user input of a sentence, and find the first appearance of the substring 'not' and 'bad' from the user input. If 'not' appears before the 'bad', the function should replace the whole 'not'...'bad' substring with 'good'. Return the resulting string. Note your function should be able to handle user input with difference cases. Example: Input = 'The ice cream is not bad!' Output = 'The ice cream is good!" Input...
8. (3pts) In your own words provide a one sentence definition/example of the following: 1. Vital...
8. (3pts) In your own words provide a one sentence definition/example of the following: 1. Vital capacity 2. Residual volume 3. Tidal volume 4. Total lung capacity 5. Functional residual capacity 6. Expiratory reserve volume 9. (2pts) Would breathing pure oxygen cause a large increase in the partial pressure of oxygen within the blood stream? Why or why not?
2 2/3 x 5/6=? •write a multipicative comparison story problem for the number sentence above. •State...
2 2/3 x 5/6=? •write a multipicative comparison story problem for the number sentence above. •State the all-at-once meaning or by whole meaning of the number sentence. •state the by-parts meaning of the number sentence. •what does the number sentence mean in words? •what is the final numerical answer?
Write a function called sum_half that takes as input a square matrix A and computes the...
Write a function called sum_half that takes as input a square matrix A and computes the sum of its elements that are in the upper right triangular part of A, that is, elements in the diagonal and elements that are to the right of it. For example, if the input is [1 2 3; 4 5 6; 7 8 9], then the function would return 26. (That is, 1+2+3+5+6+9) Note, the function triu is not allowed. Please write as you...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • An Engineering consultant appointed on the construction of a Bridge site decided to conduct the Plate...
    asked 2 minutes ago
  • Create a program in java using if statements Suppose the WIFI of a client is not...
    asked 12 minutes ago
  • W Mart, one of major retailers, reported cash flows and earning: Comprehensive income) for the firm...
    asked 24 minutes ago
  • Parker Hi-Fi Systems Parker Hi-Fi Systems, located in Wellesley, Massachusetts, a Boston suburb, assembles and sells...
    asked 24 minutes ago
  • Manufacturing companies strive to maintain production​ consistency, but it is often difficult for outsiders to tell...
    asked 35 minutes ago
  • There is a difference between statistical probability and theoretical probability. The theoretical probability of rolling a...
    asked 42 minutes ago
  • In a small struggling technology company, the employees are aware that processes and structures must change...
    asked 54 minutes ago
  • On June 30, 2018, Blue, Inc. leased a machine from Large Leasing Corporation. The lease agreement...
    asked 1 hour ago
  • You are on a mountain and see three other mountain tops that create a polygonal valley....
    asked 1 hour ago
  • Congressional Ethics: Identify one (1) member of Congress who has been charged with ethics violations in...
    asked 1 hour ago
  • A study had a statistically significant finding that walking 1 mile everyday will reduce the BMI...
    asked 1 hour ago
  • What is meant by electrical equivalent of heat. (define ) What is electrical energy and what...
    asked 1 hour ago