National University: Analysis and Visualization With Vectors and Arrays
National University: Analysis and Visualization With Vectors and Arrays
College of Engineering
Department of Electronics Engineering
EXPERIMENT NO. 3
Submitted by:
Submitted to:
Question 2:
Present in a table the maximum and the minimum electricity consumption of each countries in the data set
and the year when these occurred. Discuss any observations you can make about the data in your table.
Answer:
We can see in the table that the electricity consumption is very high in almost all of the country in the
year 2004 and in the year 1980 the consumption is very low execpt italy that has a delay of 1 year.
Question 3:
Based on the sorted year data of Italian electricity use, what can be said about the electricity consumption of
Italy? Is the same observation can be made to other countries?
Answer:
Based on the data that was gathered the electricity consumption of Italy steadily grow as the year passed.
Question 4:
Find and tabulate the changes in electricity use of all countries in ElectricityUse.mat. State your
observations about the generated data
Answer:
Country Change In
ElectricityUse
Argentina 47
Austrialia 127
Brazil 231
Canada 225
China 1694
France 211
India 373
Indonesia 89
Italy 137
Japan 440
SouthKorea 301
Mexico 128
SaudiArabia 118
SouthAfrica 114
Turkey 98
UnitedKingdom 100
UnitedStates 1622
Question 5: Find out what the available elementary mathematical functions in MATLAB are and what each
one does.
Answer:
Trigonometric.
sin - Sine.
sind - Sine of argument in degrees.
sinh - Hyperbolic sine.
asin - Inverse sine.
asind - Inverse sine, result in degrees.
asinh - Inverse hyperbolic sine.
cos - Cosine.
cosd - Cosine of argument in degrees.
cosh - Hyperbolic cosine.
acos - Inverse cosine.
acosd - Inverse cosine, result in degrees.
acosh - Inverse hyperbolic cosine.
tan - Tangent.
tand - Tangent of argument in degrees.
tanh - Hyperbolic tangent.
atan - Inverse tangent.
atand - Inverse tangent, result in degrees.
atan2 - Four quadrant inverse tangent.
atan2d - Four quadrant inverse tangent, result in degrees.
atanh - Inverse hyperbolic tangent.
sec - Secant.
secd - Secant of argument in degrees.
sech - Hyperbolic secant.
asec - Inverse secant.
asecd - Inverse secant, result in degrees.
asech - Inverse hyperbolic secant.
csc - Cosecant.
cscd - Cosecant of argument in degrees.
csch - Hyperbolic cosecant.
acsc - Inverse cosecant.
acscd - Inverse cosecant, result in degrees.
acsch - Inverse hyperbolic cosecant.
cot - Cotangent.
cotd - Cotangent of argument in degrees.
coth - Hyperbolic cotangent.
acot - Inverse cotangent.
acotd - Inverse cotangent, result in degrees.
acoth - Inverse hyperbolic cotangent.
hypot - Square root of sum of squares.
deg2rad - Convert angles from degrees to radians.
rad2deg - Convert angles from radians to degrees.
Exponential.
exp - Exponential.
expm1 - Compute exp(x)-1 accurately.
log - Natural logarithm.
log1p - Compute log(1+x) accurately.
log10 - Common (base 10) logarithm.
log2 - Base 2 logarithm and dissect floating point number.
pow2 - Base 2 power and scale floating point number.
realpow - Power that will error out on complex result.
reallog - Natural logarithm of real number.
realsqrt - Square root of number greater than or equal to zero.
sqrt - Square root.
nthroot - Real n-th root of real numbers.
nextpow2 - Next higher power of 2.
Complex.
abs - Absolute value.
angle - Phase angle.
complex - Construct complex data from real and imaginary parts.
conj - Complex conjugate.
imag - Complex imaginary part.
real - Complex real part.
unwrap - Unwrap phase angle.
isreal - True for real array.
cplxpair - Sort numbers into complex conjugate pairs.
Question 6:
Find out about the functions size, length and numel and their usage.
Answer:
Question 7: Using these, load the variables saved in gasprices.mat and show how the dimensions,
number of rows, number of columns and the number of elements can be obtained for the variables Year
and Prices.
Answer:
Number of Elements
numel (Year) = 19
numel (Prices) =190
Question 8:
Explain why each of the commands in step 5 above works or does not work.
Answer:
X*Y
X .* Y
X * x NOT WORKING
x*X
(x .* y) * Y
(y * x) * X
X*y
X/Y
X ./ Y
X ^ y NOT WORKING
X .^ Y
x ./ y'
x' ./ y
The two equation does not work because the dimensions does not match
Question 9:
Interpret the commands YearlyAvg = mean(Prices,2) and YearlyAvg = mean(Prices'). Tell the similarities and
the differences in the results of each.
Answer:
The row of the YearlyAvg = mean(Prices,2) had become columns when the command YearlyAvg = mean(Prices,2)
have been executed.
Question 10:
Plot the data inside the matrix Prices with Year on the horizontal axis. Annotate your graph with the title
Gas Prices per Country, horizontal axis label as Year and vertical axis as Prices in USD. Show
the legend with the cell array Country as the label. Save the figure as PlotMatrix.jpg and copy of this
graph with this report. Write the commands you have used to generate the plot.
Answer:
Question 11:
Save both Figure 1 and Figure 2 windows as JPEG files. Print a copy of these figure windows and attach the
printed copy into this report.
Answer:
Usage through time
5
4.5
4.5
4
3.5
3.5
3
3
2.5
2.5
2 2
01/90 07/92 01/95 07/97 01/00 07/02 01/05 07/07 01/10 2 2.5 3 3.5 4 4.5 5
Question 12:
Save both Figure 1 and Figure 2 windows as JPEG files. Print a copy of these figure windows and attach the
printed copy into this report.
Answer:
Question 13:
Print all the figure windows and attach them into this report.
Answer:
4.5 4.5
4.5
Retail consumption [109kWh/day]
4
Retail consumption [10 9kWh/day]
4
Retail consumption [109 kWh/day]
4
3.5 3.5
3.5
3 3
3
2.5 2.5
2 2.5 2
01/90 07/92 01/95 07/97 01/00 07/02 01/05 07/07 01/10 01/90 07/92 01/95 07/97 01/00 07/02 01/05 07/07 01/10
Date Date
2
01/90 07/92 01/95 07/97 01/00 07/02 01/05 07/07 01/10
Date
Question 14: Print the plot, and attach the printed copy into this report.
Answer:
5
Data
Modeled trend
4.5
Retail consumption [109 kWh/day]
3.5
2.5
2
07/92 01/95 07/97 01/00 07/02 01/05 07/07
Date
In this experiment we learn more about mathematical and statistic calculations with vectors and matrices
and, we know how to present methods on creating basic visualizations with vectors and matrices. And, this
MATLAB can interpret signals ang signal processing systems, we learn and understand some function in
MATLAB.