%------------------------------------------------------------------------ % NAME: qp_rndxH % % A function to apply a sensor matrix to a rnd spectra % % FORMAT: qp_rndxH( Q , [ Qi, do_save) ] % % OUT: - % IN: Q rnd structure. % OPTIONAL: Qi inversion structure, so H is taken from % here if Qi is given, if not obvioulsy % H from Q is applied to Q % do_save the transformed ybatch is always saved in % the same file where it was loaded, if do_ % save=1 the non transformed ybatch can be % saved in [Q.RND_DIR,Q.RND_NAME,'.ybatchraw']. % The same applies to noise. Notice that % spectra without reduction can mean very % large files. % %------------------------------------------------------------------------ % % HISTORY: 2001.08.04 Started by Carlos Jimenez % function qp_rndxH( Q, Qi, do_save) % %=== start printing out(1,1); % %=== do_save=0 default if ~exist('do_save') do_save=0; end % %=== load spectra load( [Q.RND_DIR,Q.RND_NAME,'.ybatch'], '-mat' ); % %=== load H matrix if ~exist('Qi') & ~q2n_isdata(Q) % NOTE: the data in Q is applied the sensor matrix defined in Q % e.g. a training set load( [Q.OUT,'.h'], '-mat' ); out(1,['Applying H to spectra from Q']); else % NOTE: the data in Q is applied the sensor matrix defined in Qi % e.g. Q is simulated data that has to be reduced in the % same way the training spectra was reduced. Of course, by % doing the same sensor definitions in both Q and Qi the % will not be confussions, but let's make it "idiot-proof" load( [Qi.OUT,'.h'], '-mat' ); out(1,['Applying H from Qi to spectra from Q']); end % %=== multiply spectra Y = h_x_h(H,Y); % %=== save spectra save( [Q.RND_DIR,Q.RND_NAME,'.ybatch'], 'Y' ); if do_save save( [Q.RND_DIR,Q.RND_NAME,'.ybatchraw'], 'Y' ); end clear Y % %=== load, transformed and save noise if Q.RND_THN_DO load( [Q.RND_DIR,Q.RND_NAME,'.noise'], '-mat' ); N = h_x_h(H,N); clear H save( [Q.RND_DIR,Q.RND_NAME,'.noise'], 'N' ); if do_save save( [Q.RND_DIR,Q.RND_NAME,'.noiseraw'], 'N' ); end end % out(1,-1); %