% Demonstration m script to run Caspoc from Matlab
% 1	Calculate parameters 
% 2	Export xml parameter file
% 3	Call Caspoc.exe
%
R=5;
% output capacitance 100uF
C=100e-6; % mnot used in this example
% inductor is set to 100uH
L=100e-6;
% open file and write parameters
fileID = fopen('grid.xml', 'w');
%fprintf(fileID,'Exponential Function\n\n');
%fprintf(fileID,'%6.2f %12.8f\n', R,C);
fprintf(fileID,'<?xml version="1.0" encoding="ISO-8859-1"?>\n');
fprintf(fileID,'<datamodel>\n');
fprintf(fileID,'<data>\n');
fprintf(fileID,'<parameters>\n');
fprintf(fileID,'<parameter name="1">\n');
fprintf(fileID,'<name>R</name>\n');
fprintf(fileID,'<value_si>%f</value_si>\n',R);
fprintf(fileID,'<description>resistance</description>\n');
fprintf(fileID,'</parameter>\n');
fprintf(fileID,'<parameter name="2">\n');
fprintf(fileID,'<name>L</name>\n');
fprintf(fileID,'<value_si>%f</value_si>\n',L);
fprintf(fileID,'<description>inductance</description>\n');
fprintf(fileID,'</parameter>\n');
fprintf(fileID,'<parameter name="3">\n');
fprintf(fileID,'<name>C</name>\n');
fprintf(fileID,'<value_si>%f</value_si>\n',C);
fprintf(fileID,'<description>capacitance</description>\n');
fprintf(fileID,'</parameter>\n');
fprintf(fileID,'</parameters>\n');
fprintf(fileID,'</data>\n');
fprintf(fileID,'</datamodel>\n');
fclose(fileID);
% Call Caspoc
system('c:\data\programs\caspoc2017\Caspoc2017.exe grid.csi &')