The Australian MATLAB Homework Help Service You Can Depend OnGet top-quality Matlab assignment help in Australia from our experts in Perth, Brisbane, Adelaide, and Sydney. Quality assistance for students looking for Matlab assignment help in AustraliaFor years, students in Australia have strug...
clear; clc;
sim_time = 0.1;
Voltage = 200;
alpha = 90;
alpha_arr = [ ];
vol_arr = [];
cur_arr = [];
pow_arr = [];
vol_arr1 = [];
cur_arr1 = [];
pow_arr1 = [];
figure( 1 )
for i = 1:6
sim( "FCTCR.slx" , sim_time );
pow_arr = [ pow_arr output_res( end , end ) ];
cur_arr = [ cur_arr , output_res( end , 4 ) ];
vol_arr = [ vol_arr , output_res( end , 1 ) ];
Voltage = Voltage + 5;
end
plot( pow_arr , vol_arr , 'o')
grid on
xlabel( "P[W]" )
ylabel( "V[V]" )
title( "Power vs Voltage" )
hold on
tab1 = array2table( [ vol_arr' pow_arr' cur_arr' ] , 'VariableNames',{'Voltage','Power','Current'} );
save( "table1" , "tab1" );
Voltage = 200;
alpha = 90;
alpha_arr = [ ];
vol_arr = [];
cur_arr = [];
pow_arr = [];
for i = 1:6
sim( "noFCTCR.slx" , sim_time );
pow_arr = [ pow_arr output_res_no( end , end ) ];
cur_arr = [ cur_arr , output_res_no( end , 4 ) ];
vol_arr = [ vol_arr , output_res_no( end , 1 ) ];
Voltage = Voltage + 5;
end
plot( pow_arr , vol_arr , '*r' )
grid on
xlabel( "P[W]" )
ylabel( "V[V]" )
title( "Power vs Voltage" )
hold off
tab2 = array2table( [ vol_arr' pow_arr' cur_arr' ] , 'VariableNames',{'Voltage','Power','Current'} );
save( "table2" , "tab2" );
Voltage = 220;
figure( 2 )
for i = 1:6
sim( "FCTCR.slx" , sim_time );
pow_arr1 = [ pow_arr1 output_res( end , end ) ];
cur_arr1 = [ cur_arr1 , output_res( end , 4 ) ];
vol_arr1 = [ vol_arr1 , output_res( end , 1 ) ];
alpha = alpha + 5;
alpha_arr = [ alpha_arr alpha ];
end
plot( alpha_arr , pow_arr , 'o' )
grid on
xlabel( "P[W]" )
ylabel( "Angle[deg]" )
title( "Angle vs Voltage" )
hold on
Voltage = 200;
alpha = 90;
alpha_arr = [ ];
Voltage = 220;
vol_arr1 = [];
cur_arr1 = [];
pow_arr1 = [];
for i = 1:6
sim( "noFCTCR.slx" , sim_time );
pow_arr1 = [ pow_arr1 output_res_no( end , end ) ];
cur_arr1 = [ cur_arr1 , output_res_no( end , 4 ) ];
vol_arr1 = [ vol_arr1 , output_res_no( end , 1 ) ];
alpha = alpha + 5;
alpha_arr = [ alpha_arr alpha ];
end
plot( alpha_arr , pow_arr , '*r' )
grid on
xlabel( "P[W]" )
ylabel( "Angle[deg]" )
title( "Angle vs Voltage" )
hold off
clc, clear all, close all
data = readtable('IndianBay.csv');
% First, assign an index for each existing year and month in data
% We will organize the data as a matrix MxN, where M is the number of years
% and N is the number of months
years = unique(data.Year);
months = unique(data.Month);
days = unique(data.Day);
M = length(years);
N = length(months);
meantemp = zeros(M,N);
mintemp = Inf*ones(M,N);
maxtemp = -Inf*ones(M,N);
for i = 1:size(data,1)
year = data.Year(i);
month = data.Month(i);
day = data.Day(i);
max_val = data.MaxTemp___C_(i);
min_val = data.MinTemp___C_(i);
mean_val = data.MeanTemp___C_(i);
idx_yr = find(years==year);
idx_mth = find(months == month);
if min_val < mintemp(idx_yr, idx_mth)
mintemp(idx_yr, idx_mth) = min_val;
end
if max_val > maxtemp(idx_yr, idx_mth)
maxtemp(idx_yr, idx_mth) = max_val;
end
meantemp(idx_yr, idx_mth) = meantemp(idx_yr, idx_mth) + mean_val/30;
end
mintemp(isnan(mintemp)) = 0;
mintemp(isinf(mintemp)) = 0;
maxtemp(isnan(maxtemp)) = 0;
maxtemp(isinf(maxtemp)) = 0;
meantemp(isnan(meantemp)) = 0;
meantemp(isinf(meantemp)) = 0;
%% Question 4
%% Plot minimum, maximum and average
% figure
% subplot(3,1,1)
legend_cell = {};
min_monthly_temp = zeros(M, N);
max_monthly_temp = zeros(M, N);
mean_monthly_temp = zeros(M, N);
for i = 1:length(years)
year = years(i);
idx_yr = find(years == year);
for j = 1:length(months)
month = months(j);
idx_mth = find(months == month);
temp = mintemp(idx_yr, idx_mth);
min_monthly_temp(i, j) = temp;
temp = maxtemp(idx_yr, idx_mth);
max_monthly_temp(i, j) = temp;
temp = meantemp(idx_yr, idx_mth);
mean_monthly_temp(i, j) = temp;
end
end
% plot(1:12, min_monthly_temp)
% grid on
% xlabel('Month');
%% Question 4
% ylabel('Temperature (ºC)');
% title('Min. Temperature recorded each month');
%
% subplot(3,1,2)
% plot(1:12, max_monthly_temp)
% grid on
% xlabel('Month');
% ylabel('Temperature (ºC)');
% title('Max. Temperature recorded each month');
%
% subplot(3,1,3)
% plot(1:12, mean_monthly_temp)
% grid on
% xlabel('Month');
% ylabel('Temperature (ºC)');
% title('Mean Temperature recorded each month');
%% Plot min, max and mean for each month from beginning to end
meantemp_month = reshape(mean_monthly_temp, [1, size(mean_monthly_temp,1)*size(mean_monthly_temp,2)]);
mintemp_month = reshape(min_monthly_temp, [1, size(min_monthly_temp,1)*size(min_monthly_temp,2)]);
maxtemp_month = reshape(max_monthly_temp, [1, size(max_monthly_temp,1)*size(max_monthly_temp,2)]);
figure
subplot(3,1,1)
plot(1:length(meantemp_month), meantemp_month)
xlabel('Months from the beginning of data');
ylabel('Mean T in degree C');
grid on
subplot(3,1,2)
plot(1:length(mintemp_month), mintemp_month)
xlabel('Months from the beginning of data');
ylabel('Min T in degree C');
grid on
subplot(3,1,3)
plot(1:length(maxtemp_month), maxtemp_month)
xlabel('Months from the beginning of data');
ylabel('Max T in degree C');
grid on
%% Question 5
% Divide into 12 time series
min_months = min(mintemp)';
max_months = max(maxtemp)';
mean_months = mean(meantemp)';
mode_months = mode(meantemp)';
median_months = median(meantemp)';
std_months = std(meantemp)';
% Tab = table(min_months, max_months, mean_months, mode_months, median_months, std_months, 'RowNames', {'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'})
month_names = {'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'};
for i = 1:12
meanmin(i,1) = min(meantemp(:,i));
meanmax(i,1) = max(meantemp(:,i));
meanmean(i,1) = mean(meantemp(:,i));
meanmedian(i,1) = median(meantemp(:,i));
meanmode(i,1) = mode(meantemp(:,i));
meanstd(i,1) = std(meantemp(:,i));
minmin(i,1) = min(min_monthly_temp(:,i));
minmax(i,1) = max(min_monthly_temp(:,i));
minmean(i,1) = mean(min_monthly_temp(:,i));
minmedian(i,1) = median(min_monthly_temp(:,i));
minmode(i,1) = mode(min_monthly_temp(:,i));
minstd(i,1) = std(min_monthly_temp(:,i));
maxmin(i,1) = min(maxtemp(:,i));
maxmax(i,1) = max(maxtemp(:,i));
maxmean(i,1) = mean(maxtemp(:,i));
maxmedian(i,1) = median(maxtemp(:,i));
maxmode(i,1) = mode(maxtemp(:,i));
maxstd(i,1) = std(maxtemp(:,i));
end
MeanTab = table(meanmin, meanmean, meanmedian, meanmode, meanmax, meanstd);
MeanTab.Properties.RowNames = month_names;
disp(MeanTab)
MinTab = table(minmin, minmean, minmedian, minmode, minmax, minstd);
MinTab.Properties.RowNames = month_names;
disp(MinTab)
MaxTab = table(maxmin, maxmean, maxmedian, maxmode, maxmax, maxstd);
MaxTab.Properties.RowNames = month_names;
disp(MaxTab)
%% Question 6
% Fit a line for only the mean timeseries
% Apply a linear fit
x = 1:40; % months
slopvecmean = zeros(12,1);
slopvecmax = zeros(12,1);
slopvecmin = zeros(12,1);
figure
fprintf("Slopes for mean temp...\n");
for i = 1:length(months)
y = meantemp(:,i)'; % Mean temperature per month during 40 years
col = rand(1,3);
subplot(4,4,i);
plot(min(years)+x, y, 'linewidth', 2), hold on
c = polyfit(x,y,1);
disp(['Equation for ', month_names{i}, ' is y = ' num2str(c(1)) '*x + ' num2str(c(2))])
y_est = polyval(c, x);
plot(min(years)+x, y_est, 'linewidth', 2)
title(month_names{i});
grid on
% legend('Original', 'Fitted');
xlabel('Year');
ylabel('ExtMean T');
slopvecmean(i) = c(1);
end
fprintf("\n");
figure
fprintf("Slopes for min temp...\n");
for i = 1:length(months)
y = mintemp(:,i)'; % Min temperature per month during 40 years
col = rand(1,3);
subplot(4,4,i)
plot(min(years)+x, y, 'linewidth', 2), hold on
c = polyfit(x,y,1);
disp(['Equation for ', month_names{i}, ' is y = ' num2str(c(1)) '*x + ' num2str(c(2))])
y_est = polyval(c, x);
plot(min(years)+x, y_est, 'linewidth', 2)
title(month_names{i});
grid on
% legend('Original', 'Fitted');
xlabel('Year');
ylabel('ExtMin T');
slopvecmin(i) = c(1);
end
fprintf("\n");
figure
fprintf("Slopes for max temp...\n");
for i = 1:length(months)
y = maxtemp(:,i)'; % Max temperature per month during 40 years
col = rand(1,3);
subplot(4,4,i)
plot(min(years)+x, y, 'linewidth', 2), hold on
c = polyfit(x,y,1);
disp(['Equation for ', month_names{i}, ' is y = ' num2str(c(1)) '*x + ' num2str(c(2))])
y_est = polyval(c, x);
plot(min(years)+x, y_est, 'linewidth', 2)
title(month_names{i});
grid on
% legend('Original', 'Fitted');
xlabel('Year');
ylabel('ExtMax T');
slopvecmax(i) = c(1);
end
% Generate table of slopes
SlopesTab = table(slopvecmean, slopvecmax, slopvecmin);
SlopesTab.Properties.RowNames = month_names;
disp(SlopesTab)
%% Question 6
% From figures generated by the code above, there are months where the
% trend is increasing, and some others for a decreasing trend.