BootCamp2012: spiro.m

File spiro.m, 1.4 KB (added by mmc, 2 years ago)

Solution for Assignment #4

Line 
1% ----------------------------------------------------------------------
2%  MAIN PROGRAM - generated by the Rappture Builder
3% ----------------------------------------------------------------------
4
5% open the XML file containing the run parameters
6% the file name comes in from the command-line via variable 'infile'
7io = rpLib(infile);
8
9%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10% Get input values from Rappture
11%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
13% get input value for input.number(n1)
14n1 = rpLibGetDouble(io,'input.number(n1).current');
15
16% get input value for input.number(n2)
17n2 = rpLibGetDouble(io,'input.number(n2).current');
18
19% get input value for input.number(n3)
20n3 = rpLibGetDouble(io,'input.number(n3).current');
21
22
23%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24%  Add your code here for the main body of your program
25%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26t = linspace(0, 1, 1000);
27z = exp(i*2*pi*n1*t) + exp(i*2*pi*n2*t) + exp(i*2*pi*n3*t);
28
29%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30% Save output values back to Rappture
31%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
33% save output value for output.curve(z)
34% this assumes a vector 'x' and a vector 'y'
35xydata = [real(z);imag(z)];
36str = sprintf('%12g %12g\n', xydata);
37rpLibPutString(io,'output.curve(z).component.xy',str,0);
38
39
40rpLibResult(io);
41quit;