matlab - How to transform this in a function taking my load as parameters and add a play button to move the graph? -


it's matlab code want pass load parameter

function test     a=axes('position',[0.05,0.75,0.9,0.2])     load('filteredsignal.mat');//want pass parameter      fs = 1000;              // sampling rate     n = length (filteredsignal(1,:));       // signal length     t = [0:n-1]/fs;              plot(t, filteredsignal,'r');     yl = get(a,'ylim');     hold on     x=1:70     plot([x x],yl,'k:');     end     // dr width of axis 'window'     dr=10;     // avoids flickering when updating axis     set(a,'xlim',[0 dr]);     // generate constants use in uicontrol initialization     pos=get(a,'position');     newpos=[pos(1) pos(2) pos(3) 0.02];     xmax=max(t);     s=['set(gca,''xlim'',get(gcbo,''value'')+[0 ' num2str(dr) '])'];     // create slider underneath axis     // still leaves room axis labels above slider     h=uicontrol('style','slider',...         'units','normalized','position',newpos,...         'callback',s,'min',0,'max',xmax-dr);   end 

alter first line to:

function [] = test(filename) 

and change load line to:

load(filename) 

this way it's input parameter. make sure pass file name string though, i.e. filename = 'filteredsignal.mat';


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -