C AaBbCc 91 Heading 2 Title Subtitle Subtle Em... Emphasis Intense E... Strong Q
ID: 3706436 • Letter: C
Question
C AaBbCc 91 Heading 2 Title Subtitle Subtle Em... Emphasis Intense E... Strong Quote Intense . Subtle Ref. I Styles Using the wind energy data set below, write a matlab script that include the following http://data un org/Data aspx?d-EDATA&f-cmlD;%3aEw The script file(s) must cover 6 out of the 8 Lecture topics from class (see topics below). Each include 1) Input statements 2) Output statements 3) Reading data from Excel into Matlab (xlsread) 4) Graphing in MATLAB (use both the plot, imshow, or bar commands) Try to have at least two figures generated from graphing 5) Conditional Statements (if-elseit-else-end / switch-case) 6) Loops (For / While) 7) Aray Operations (Array Math and Array conditional statements) 8) Array Applications (Handling Data Files, this is easy since it is the project topic) In your code, you must identify with comment lines where you actually apply the above topicsExplanation / Answer
%% input statement
prompt = 'Input: ';
x = input(prompt); %input
%% output statement
disp(x); %output
%% read data from excel to matlab
filename = 'myExample.xlsx';
A = xlsread(filename); %fileread
%% graphing in matlab
x = 0:pi/100:2*pi; % x from 0 to 2*pi with increment of pi/100
y = sin(x);
plot(x,y) %plot
I = imread('file.jpeg');
imshow(I); %imshow
x = 1900:10:2000; % x from 1900 to 2000 and icrement is 10
y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
bar(x,y) %bar
%% conditional if-elseif-else
a=60;
if a < 30
disp('small');
elseif a < 80
disp('medium');
else
disp('large');
end
%% switch case
n = input('Enter a number: ');
switch n
case -1
disp('negative one')
case 0
disp('zero')
case 1
disp('positive one')
otherwise
disp('other value')
end
%% loops
x = ones(1,10);
for n = 2:6 % n is from 2 to 6 with 1 incremental
x(n) = 2 * x(n - 1);
end
%% array operation
A = [1 1 1]
B = [1 2 3]
C = A + B;
disp(C);
%% array with .net application
d1 = NET.createArray('System.String',3);
d1.Set(0, 'one'); % assigning through set function
d1.Set(1, 'two');
d1.Set(2, 'three');
d2 = NET.createArray('System.String',3);
d2(1) = 'one'; % direct assigning
d2(2) = 'two';
d2(3) = 'zero';
System.String.Compare(d1(1),d2.Get(0)) % compare values of the first elements in each array
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.