Code covered by the BSD License  

Highlights from
Benchmark Problem 02 - Matlab Code

image thumbnail

Benchmark Problem 02 - Matlab Code

by

 

21 May 2013 (Updated )

This is the Matlab code for the model Benchmark Problem 02.

testcasegen_random.m
% Random test waveform generator. You can change the par variable to change
% the Frequency Amplitude and Bias values.
clc
clear all
DT=0.02;
dt=DT;
t=0:dt:60;t=t';time=t;   % Define time vector
warning off
par=[0.22 22 22 0.22 22 22 0.22 3.3 3.3 0.22 44 22 0.22 11 11 0.22 44 22 0.66 11 22 0.22 22 22 0.22 22 22 0.22 22 22 0.22 22 22 0.22 3.3 3.3 0.22 3.3 3.3 0.22 3.3 3.3 0.22 3.3 3.3 0.22 66 44 0.22 11 5.5 0.22 22 22 0.22 22 22 0.11 22 33 0.22 11 11];
r=1;
save temp r

for ix = 1:1000
    
%Generate A1, A2, ... A21 input profiles as random sinusoidal waveforms

f1=0.01+rand*par(1); a1=0.1+rand*par(2); b1=rand*par(3)-par(3)/2;
A1=(sin(2*pi*f1*t)*a1)+b1;
testcases(ix,1) = f1; testcases(ix,2) = a1; testcases(ix,3) = b1;
f2=0.01+rand*par(4); a2=0.1+rand*par(5); b2=rand*par(6)-par(6)/2;
A2=(sin(2*pi*f2*t)*a2)+b2;
testcases(ix,4) = f2; testcases(ix,5) = a2; testcases(ix,6) = b2;
f3=0.01+rand*par(7); a3=0.1+rand*par(8); b3=rand*par(9)-par(9)/2;
A3=(sin(2*pi*f3*t)*a3)+b3;
testcases(ix,7) = f3; testcases(ix,8) = a3; testcases(ix,9) = b3;
f4=0.01+rand*par(10); a4=0.1+rand*par(11); b4=rand*par(12)-par(12)/2;
A4=(sin(2*pi*f4*t)*a4)+b4;
testcases(ix,10) = f4; testcases(ix,11) = a4; testcases(ix,12) = b4;
f5=0.01+rand*par(13); a5=0.1+rand*par(14); b5=rand*par(15)-par(15)/2;
A5=(sin(2*pi*f5*t)*a5)+b5;
testcases(ix,13) = f5; testcases(ix,14) = a5; testcases(ix,15) = b5;
f6=0.01+rand*par(16); a6=0.1+rand*par(17); b6=rand*par(18)-par(18)/2;
A6=(sin(2*pi*f6*t)*a6)+b6;
testcases(ix,16) = f6; testcases(ix,17) = a6; testcases(ix,18) = b6;
f7=0.01+rand*par(19); a7=0.1+rand*par(20); b7=rand*par(21)-par(21)/2;
A7=(sin(2*pi*f7*t)*a7)+b7;
testcases(ix,19) = f7; testcases(ix,20) = a7; testcases(ix,21) = b7;
f8=0.01+rand*par(22); a8=0.1+rand*par(23); b8=rand*par(24)-par(24)/2;
A8=(sin(2*pi*f8*t)*a8)+b8;
testcases(ix,22) = f8; testcases(ix,23) = a8; testcases(ix,24) = b8;
f9=0.01+rand*par(25); a9=0.1+rand*par(26); b9=rand*par(27)-par(27)/2;
A9=(sin(2*pi*f9*t)*a9)+b9;
testcases(ix,25) = f9; testcases(ix,26) = a9; testcases(ix,27) = b9;
f10=0.01+rand*par(28); a10=0.1+rand*par(29); b10=rand*par(30)-par(30)/2;
A10=(sin(2*pi*f10*t)*a10)+b10;
testcases(ix,28) = f10; testcases(ix,29) = a10; testcases(ix,30) = b10;
f11=0.01+rand*par(31); a11=0.1+rand*par(32); b11=rand*par(33)-par(33)/2;
A11=(sin(2*pi*f11*t)*a11)+b11;
testcases(ix,31) = f11; testcases(ix,32) = a11; testcases(ix,33) = b11;
f12=0.01+rand*par(34); a12=0.1+rand*par(35); b12=rand*par(36)-par(36)/2;
A12=(sin(2*pi*f12*t)*a12)+b12;
testcases(ix,34) = f12; testcases(ix,35) = a12; testcases(ix,36) = b12;
f13=0.01+rand*par(37); a13=0.1+rand*par(38); b13=rand*par(39)-par(39)/2;
A13=(sin(2*pi*f13*t)*a13)+b13;
testcases(ix,37) = f13; testcases(ix,38) = a13; testcases(ix,39) = b13;
f14=0.01+rand*par(40); a14=0.1+rand*par(41); b14=rand*par(42)-par(42)/2;
A14=(sin(2*pi*f14*t)*a14)+b14;
testcases(ix,40) = f14; testcases(ix,41) = a14; testcases(ix,42) = b14;
f15=0.01+rand*par(43); a15=0.1+rand*par(44); b15=rand*par(45)-par(45)/2;
A15=(sin(2*pi*f15*t)*a15)+b15;
testcases(ix,43) = f15; testcases(ix,44) = a15; testcases(ix,45) = b15;
f16=0.01+rand*par(46); a16=0.1+rand*par(47); b16=rand*par(48)-par(48)/2;
A16=(sin(2*pi*f16*t)*a16)+b16;
testcases(ix,46) = f16; testcases(ix,47) = a16; testcases(ix,48) = b16;
f17=0.01+rand*par(49); a17=0.1+rand*par(50); b17=rand*par(51)-par(51)/2;
A17=(sin(2*pi*f17*t)*a17)+b17;
testcases(ix,49) = f17; testcases(ix,50) = a17; testcases(ix,51) = b17;
f18=0.01+rand*par(52); a18=0.1+rand*par(53); b18=rand*par(54)-par(54)/2;
A18=(sin(2*pi*f18*t)*a18)+b18;
testcases(ix,52) = f18; testcases(ix,53) = a18; testcases(ix,54) = b18;
f19=0.01+rand*par(55); a19=0.1+rand*par(56); b19=rand*par(57)-par(57)/2;
A19=(sin(2*pi*f19*t)*a19)+b19;
testcases(ix,55) = f19; testcases(ix,56) = a19; testcases(ix,57) = b19;
f20=0.01+rand*par(58); a20=0.1+rand*par(59); b20=rand*par(60)-par(60)/2;
A20=(sin(2*pi*f20*t)*a20)+b20;
testcases(ix,58) = f20; testcases(ix,59) = a20; testcases(ix,60) = b20;
f21=0.01+rand*par(61); a21=0.1+rand*par(62); b21=rand*par(63)-par(63)/2;
A21=(sin(2*pi*f21*t)*a21)+b21;
testcases(ix,61) = f21; testcases(ix,62) = a21; testcases(ix,63) = b21;    


Original  % Run the Matlab code

end





Contact us