1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| %% Build Standalone executable
disp('Building standalone executable for test.slx');
test_param
Model_Name = 'test';
rtwbuild(Model_Name);
disp('Finished building standalone executable for test.slx');
%% Creat Rsim parameter files
disp(' '); disp('Creating RSIM parameter files...');
n = 1 ;
[rtpstruct]=rsimgetrtp(Model_Name);
save test_parameters_1 rtpstruct ;
n = 100 ;
[rtpstruct]=rsimgetrtp(Model_Name);
save test_parameters_100 rtpstruct ;
n = 500 ;
[rtpstruct]=rsimgetrtp(Model_Name);
save test_parameters_500 rtpstruct ;
n = 1000 ;
[rtpstruct]=rsimgetrtp(Model_Name);
save test_parameters_1000 rtpstruct ;
disp('Finished creating RSIM parameter files...');
%% Run Standalone executable
disp(' '); disp('Running RSIM simulations...');
!test -p test_parameters_1.mat -o results_1.mat
!test -p test_parameters_100.mat -o results_100.mat
!test -p test_parameters_500.mat -o results_500.mat
!test -p test_parameters_1000.mat -o results_1000.mat
disp('Finished RSIM simulations...');
%% Plot Results
figure(1)
load results_1.mat; HS_h(1)=plot(rt_tout,rt_yout(:,3));
hold on;
load results_100.mat; HS_h(1)=plot(rt_tout,rt_yout(:,3));
load results_500.mat; HS_h(1)=plot(rt_tout,rt_yout(:,3));
load results_1000.mat; HS_h(1)=plot(rt_tout,rt_yout(:,3));
hold off;
set(HS_h,'LineWidth',3);
title_h = title('Harvested Power');
xlabel_h = xlabel('Time (s)');
ylabel_h = ylabel('Power (W)');
set(title_h,'FontSize',14);
set(ylabel_h, 'FontSize', 12);
grid on
legend(HS_h,'n = 1', 'n = 100', 'n = 500', 'n = 1000', 'Location', 'SouthEast'); |
Partager