Here is the code for the first 4 problems:
% Store a number with a decimal place in a double variable (the default).
% Convert the variable to type int32 and store the result in a new variable.
doubleVariable = 34.5678;
intVariable = int32(doubleVariable);
fprintf('%f after converting to int32 will become %d\n', doubleVariable, intVariable);
% Create a variable ftemp to store a temperature in degrees Fahrenheit (F).
% Convert this to degrees Celsius (C) and store the result in a variable
% ctemp. The conversion factor is C = (F - 32) * 5/9.
ftemp = 100;
ctemp = (ftemp - 32) * 5 / 9;
fprintf('100 degrees Fahrenheit is: %f degrees centigrade.\n', ctemp);
% What would be the result of the following expressions? Write the script to
% produce the results. State your reasoning in the comments in your script.
value = 'b' >= 'c' - 1; %This expression results in true, i.e., 1.
%This is because, the ASCII value of 'b' is 66, and that of C is 67,
%And 66 >= 67 - 1 ==> 66 >= 66 will evaluate to true.
fprintf('''b'' >= ''c'' - 1 is: %d\n', value);
value = 3 == 2 + 1; %This expression results in true, i.e., 1.
%This is because, 2 + 1 is 3, and 3 == 3 will evaluate to true.
fprintf('3 == 2 + 1 is: %d\n', value);
value = (3 == 2) + 1; %This expression results in 0 + 1 = 1.
%This is because, (3 == 2) evaluates to false, and false i.e., 0 + 1
%evaluates to 1.
fprintf('(3 == 2) + 1 is: %d\n', value);
value = xor(5<6, 8>4); %This expression results in false, ie., 0
%This is because, 5<6 evaluates to true, i.e., 1, and 8 > 4 evaluates
%to true, and xor(true, true) is false, i.e., 0.
fprintf('xor(5<6, 8>4) is: %d\n', value);
%A chemical plant releases an amount A of pollutant into a stream. The
%maximum concentration of the pollutant at a point which is a distance x
%from the plant is: C = A/x (sqrt(2/(pi*e))).
%Create variables for the values of A and x, and then for C. Assume the
%distance x is in meters. Experiment with different values of x. (e in this
%case is Eulers number, 2.71828).
A = 10;
x = 5 : 10;
C = A./x .* (sqrt(2/(pi*exp(1))));
fprintf('The values of C are: ');
disp(C);
And the output screenshot is:
You need to write scripts for all problems. Each script should contain the comments on each...
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...
In this assignment, you will demonstrate your ability to write simple shell scripts. This is a cumulative assignment that will challenge you to pull together a variety of lessons from throughout the course. 2 The Assignment Every now and then, I find myself with a large number of files that have inappropriate extensions (the set of characters in the file name after the last :') that need to be changed. For example, a complicated C++ program, developed by someone on...
For this project, each part will be in its oun matlab script. You will be uploading a total 3 m files. Be sure to make your variable names descriptive, and add comments regularly to describe what your code is doing and hou your code aligns with the assignment 1 Iterative Methods: Conjugate Gradient In most software applications, row reduction is rarely used to solve a linear system Ar-b instead, an iterative algorithm like the one presented below is used. 1.1...
abe 2 Use the provided HTML for the following questions. You only need to write the JavaScript code for the following questions. No need to write a full JavaScript application. Ex. if I said "Set a myVar variable equal to 2" you would simply write myVar = 2; Please write your code in a separate file. The file MUST be named with the following format lastname_firstname.js. Use comments to divide the questions on the single JavaScript file. Example, for question...
write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve differential equations. Implementation: MatLab is an ideal environment for solving differential equations. Differential equations are a vital tool used by engineers to model, study and make predictions about the behavior of complex systems. It not only allows you to solve complex equations and systems of equations it also allows you to easily present the solutions in graphical form....
I need help solving this in c++ using visual Studio. For this assignment, you will be filling in missing pieces of code within a program, follow the comments in the code. These comments will describe the missing portion. As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. // TicTacToe.cpp: Follow along with...
CODE GIVEN % Create a program to plot the motion of the ping pong ball with drag. % The program will take inputs for velocity in m/s and angle of launch. % note that with a high speed camera I estmated a launch speed for a ping % pong ball could be 30 m/s. vel=30; %m/s angle=60; % convert the degrees into radians so MATLAB likes it angle=angle*pi/180; % set initial values (time, distance, mass, gravity, drag) x(1)=0; % meters...