Write a MATLAB script that will prompt the user to enter two
Write a MATLAB script that will prompt the user to enter two data series (series 1, series 2) and a string (title of the plot). Plot a graph with series-1 in x-axis, series-2 in y-axis and use the string as the title of the plot.
Use MATLAB function called “MyFunction” (you need to define it) The function will take one data array as input argument and calculate it’s Total, Average, and Standard-deviation. Use this function to calculate the total, average and std-dev of series-2 and print the result with proper labeling.
Example:
>> Please enter series-1:
>> Please enter series-2:
>> Please enter the title:
[Not it will plot the data with proper title]
[also it will print…
The total for data series-2 is: ____
The average is: _____
The standard deviation is: ______
]
Solution
The required function is :
function [ ] = MyFunction(z)
disp(\'The total for data series-2 is:\');sum(z)
disp(\'The average is:\');mean(z)
disp(\'The standard deviation is:\');std(z)
end
The required script is:
clc; clear all; close all;
prompt1 = \'Please enter series-1:\';
x1 = input(prompt1);
prompt2 = \'Please enter series-2:\';
x2 = input(prompt2);
prompt3 = \'Please enter the title:\';
str = input(prompt3,\'s\');
plot(x1,x2);title(str);
MyFunction(x2);
