Question

Create a single script (.m file) to complete this assignment. Unless directed otherwise, use meaningful variable names for ea
1. The quintessential program most students write when they first learn I/O is the Hello, World program. A Hello, World p
2. Repeat b) of Problem 1, but this time instead write the result to a text file on the desktop of your machine. Please note
4. Write MATLAB code to prompt the user to enter a row or column vector. Then, calculate the mean of that vector. Print the v
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Code:

clc;
clear;

%% (1) Printing hello world
% Using disp
disp("Hello World")
fprintf("Hello World\n")

%% (2) Printing hello world to file
% Opening file for writing
fileID = fopen('hello.txt', 'w')
% Writing hello world to file
fprintf(fileID, "Hello World")

%% (4) Reading row or column vector from user and printing mean
vec = input("Enter a row/column vector: ")
% Calculating mean
fprintf("Mean of the vector: %f\n", mean(vec))

_________________________________________________________________________________________________________________________

Sample Run:

Command Window Hello World Hello World fileID - 4 Enter a row/column vector: [1 2 3 4 5] vec = 1 2 3 4 5 Mean of the vector:

Add a comment
Know the answer?
Add Answer to:
Create a single script (.m file) to complete this assignment. Unless directed otherwise, use meaningful variable...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use...

    In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use meaningful variable names for each variable; do not use the default variable ans to store your results. For this project, suppress your output with semi-colons (;). Each problem should be in a separate cell, using the cell mode feature of MATLAB. Problem 4 Video games are rather complicated to program, not least of which because of the graphics work that needs to be completed...

  • use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a...

    use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a for loop with k = 1 to 8 to sum the terms in this sequence: x(k) = 1/3 Before the loop set sumx = 0 Then add each term to sumx inside the loop. (You do not need to store the individual values of the sequence; it is sufficient to add each term to the sum.) After the loop, display sumx with either disp()...

  • Using mat lab to do it Create a single script file named yourname_While.m to answer the...

    Using mat lab to do it Create a single script file named yourname_While.m to answer the following problems. The file must be in cell mode to distinguish each problem. Make sure your script is nicely commented for each problem. Consider the following matrix of values: x =[345, 23, 17, 34, 85, 334, 111, 1067] Use a for loop and if statement to determine how many values greater than 30? Use fprintf to display the result. Repeat Problem 1., but use...

  • Please use Matlab to solve and show your full codes Write a script file Ask the...

    Please use Matlab to solve and show your full codes Write a script file Ask the user to enter sides of a triangle: a, b, c Check to see if the sides are all greater than 0 If they are: Use the function (triangle) that you created in your last homework problem (HW#5 problemttF) to calculate the area. command Display the results on the screen using fprintf write the results to disk using the fprintf command. If any of the...

  • DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the...

    DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the following calculations. Your script will use the functions you create. Label all graphs appropriately. For this project, do not have your homemade functions fprintf anything, instead have all your fprintf commands within your script. Attach your published script file along with .m files for your functions. Exercise 1. A fundamental iterative method for finding the roots of equations of one-variable is known as Newton's...

  • (a) (4 points) Fill in the blanks in the following MATLAB function M file trap so...

    (a) (4 points) Fill in the blanks in the following MATLAB function M file trap so that it implements the composilu trapezidul rulo, using a soquence of w -1,2, 4, 8, 16,... trapezoids, to approximatel d . This M file uses the MATLAB built-in function trapz. If 401) and y=() f(!)..... fr. 1)). 3= ($1, then the execution of z = trapz(x, y) approximates using the composite trapezoidal rule (with trapezoids). (Note that the entries of are labeled starting at...

  • (use filename system: lastname_tempdata_firstinitial.m) 1. Gilat Chapter 6 Chapter7 #6. Use a single M-file and use...

    (use filename system: lastname_tempdata_firstinitial.m) 1. Gilat Chapter 6 Chapter7 #6. Use a single M-file and use mnemonic variable names of 3 characters or more for the variables to complete the problem. This is a comparison problem. If, selection, statements are not required but may be used. Loops are not required but may be used. Do not add any user defined M-files for this problem. Use fprintf statements to show the answer to each scenario: a), b), c), d), e) Investigate...

  • Using c++ 1 of 2 Assignment 5 Lab Section 3 write a program create a vector...

    Using c++ 1 of 2 Assignment 5 Lab Section 3 write a program create a vector with random numbers. Use merge sort to reorder the vector Prompt user to enter a number to search in the vector. If there are more than one number in the vector equal to the search value, display the indices remove the repeated numbers. If found just one matching number, display the index. If no matching number, prompt user for 2 options: add to the...

  • 3. Create a script. Save your script to your desktop. Complete the following: a) Write your name and section number on separate lines; use separate comments to accomplish this 1.2 2.3 b) Define a var...

    3. Create a script. Save your script to your desktop. Complete the following: a) Write your name and section number on separate lines; use separate comments to accomplish this 1.2 2.3 b) Define a variable -3.9and a variabley 7.5storing the results as variables x and y respectively c) Add π to each element of x and store the result as the variable x; add e to each element of y and store the new result as the variable y. Do...

  • Question #1 (15 Marks) a) (8 Marks) Answer the following questions with True or False. 1) 2) 3) Every basic solution in the assignment problem is necessarily degenerate. The assignment problem ca...

    Question #1 (15 Marks) a) (8 Marks) Answer the following questions with True or False. 1) 2) 3) Every basic solution in the assignment problem is necessarily degenerate. The assignment problem cannot be solved using the transportation technique. If the gradient vector of a function at a given point is zero, the point can only be a maximum or minimum. If a single-variable function has two local minima, it must have at least one local 4) maximum 5) The Golden...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT