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:](http://img.homeworklib.com/questions/bc49a8a0-bd76-11eb-9d7d-c532303ade25.png?x-oss-process=image/resize,w_560)
Create a single script (.m file) to complete this assignment. Unless directed otherwise, use meaningful variable...
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 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 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 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 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...
MATLAB HW 11 problem using Switch Case and Input commands Write a script file that calculates the cost of a movie tickets according to the following price schedule: Number of Tickets being purchased Time of Movie < =5 tickets 6 to 9 tickets >=10 tickets Afternoon $6 $30 + $5 for the number of tickets above 5 $50 + $4 for the number of tickets above 9 Weeknight $7 $35 + $6 for the number of tickets above 5...
1. Write an Octave script (lab02_01.m), perform the following operation. (a) Create two variable a1=5, a2=7; (a) Create a vector t from 0 to 2 with step size to 0.001; (b) Create a vector sig of a1sin(22t)+a2sin(24t); (c) Plot the vector sig vs t in a subplot region 1; (d) Using For, While, if statement, perform the following operation (i) sig_2 = sig if sig>0 (ii) sig_2=-sig*2+1 if sig<0...
(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 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 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...