Skip to content
Snippets Groups Projects
Select Git revision
  • ac1cb7a272ca4097bc9ca17a6e828e41cb03de1e
  • master default protected
2 results

FT_example2.m

Blame
    • adf's avatar
      ef25ce70
      · ef25ce70
      adf authored
      adding current code of SimTools.
      
      ef25ce70
      History
      adf authored
      adding current code of SimTools.
      
    FT_example2.m 1.29 KiB
    
    clear all;
    
    % name of kat file which contains 'blocks'
    inname='testblock.kat';
    % name of file that we will create now from this script
    katname='mytest.kat';
    
    % read in block from testblock.kat
    block=FT_read_blocks_from_file(inname);
    
    % now selectively copy some blocks from the list 'block' over
    % into the list 'outbl'.
    % we can access the block usually by name or by index:
    outbl(1)=FT_copy_block(block,2); %second block is the 'laser'
    outbl(2)=FT_copy_block(block,'cavity');
    outbl(3)=FT_copy_block(block,'detection');
    
    % create a new block by hand, containing just an xaxis command
    outbl(4)=FT_create_new_block('command1');
    outbl(4)=FT_add_line_to_block(outbl(4),'xaxis m1 phi lin 0 10 100');
    
    % write all blocks from list 'outbl' to file 'mytest.kat'
    FT_write_blocks_into_file(outbl,katname);
    
    % BTW we can also delete from the block
    % e.g. this finds all lines containing an 'm'
    xxx=FT_find_text_in_block(outbl(2),'m');
    % and now we delete them
    outbl(2)=FT_remove_lines_from_block(outbl(2),xxx);
    
    % the following is the same as in FT_example1.m
    % initialise Finesse
    FT=FT_create_new_FT();
    FT=FT_check_for_kat_binary(FT);
    
    % run Finese and read data
    Run1=FT_create_new_kat_run();
    Run1.filename=katname;
    Run1=FT_run_kat_simulation(FT,Run1);
    
    % plot data
    plot(Run1.x,Run1.y)
    
    % clean directory again
    %FT_kat_clean(Run1);