Using octave, Write a script that prompts the user for a vector of multiple measurements of a cylinder’s radius. The script should then prompt the user for a vector of multiple measurements of a cylinder’s height. The volume v of a cylinder with radius r and height h is given by v = πr2h. The script should then calculate and print the volume obtained for each pair of trial measurements. The script should work for any number of trial measurements. Sample output: Enter a vector of radius data: [ 5.499 5.498 5.5 5.5 5.52 5.51 5.5 5.48 ] Enter a vector of height data: [ 11.1 11.12 11.09 11.11 11.11 11.1 11.08 11.11 ] The volume for each trial is: 1054.5 1056.0 1053.9 1055.8 1063.5 1058.7 1053.0 1048.2 Enter a vector of radius data: [ 10.1 9.9 10.05 ] Enter a vector of height data: [ 3.1 3.0 2.9 ] The volume for each trial is: 993.47 923.72 920.20. Also, use disp to print entire vectors of numbers.
Please find the solution below:
Solution:
Steps for the script are as follows:
Prompt and Read the radius vector from the user.
Prompt and Read the height vector from the user.
Calculate the volume as per the given formula.
Note that you need to use the .* for the vector
multiplication.
Display the volume to the user.
Sample Octave
Script:
%%%%%%%%%%%%%%%%%%%%%%%%%
% Sample script to calculate the volume vector
%%%%%%%%%%%%%%%%%%%%%%%%%
% read the input
rValues=input("vector of multiple measurements of Radius:","s")
% split the string delimited by space
r=cellfun("str2num",strsplit(rValues," "))
hValues=input("vector of multiple measurements of Height:","s")
% split the string delimited by space
h=cellfun("str2num",strsplit(hValues," "))
% Calculate volume as per v = πr2h
v=pi.*r.*r.*h
%Display the volume vector
disp(v);
%%%%%%%%%%%%%%%%%%%%%%%%
Hope this helps.
Using octave, Write a script that prompts the user for a vector of multiple measurements of...
Using Matlab or Octave, I do not know how to write the script for this problem, please help. Must match sample output 5. Consider a 3 x 3 matrix given by A = 01 012 013 az az 633 ( dai 632 033 The trace of A is defined as tr(A)=2au. Given another 3 x 3 matrix bu bı2 bia B- bi brz bra | bgi bz2 by it can be shown that trAB') = tr(AB). Write a script that...
Nay programming languge is fine (MatLab, Octave, etc.) This is the whole document this last picture i sent is the first page 5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 tt r) as output argument. Paste the function code below. Paste code here 6. Validate your Sphere Area function from the command line, checking the results against hand calculations. Paste the command line code and results below. 7. Design an...