structfun(@plot,Data)
Data is a struct with different trials:
eg.
size(Data.trial1)=158 1
I like to change the color as in the following code
plot(Data.trial1,'r')
Can everybody help me?
Best,
Kai
I like .. the way you write. Try this:
create an m-file named makeitred, containing
function sth = makeitred(x)
sth = plot(x,'r')
Then write to command window:
a = [1,2,3,4,5]; b = [3,4,6,6,4,45,446,4,34]; c = [2,454,555,5]; S.a = a; S.b = b; S.c = c;
LHS = structfun(@makeitred,S)
I suppose you will like to add a few more commands to the makeitred function, as e.g. save / export your figure, formatting, labeling, etc. You can also specify the function with more than one input. Come with more questions if you get stuck again. Best of luck.
Hi Kai, perhaps you want something like:
test = struct('data1',randn(158,1), 'data2',cos(2*pi*(1/2)*(0:99)));
axes('NextPlot','add');
A = structfun(@plot,test,'UniformOutput',false);
set(A.data1,'color','r');
Hope that helps,
Wayne
linehandles = structfun(@plot,Data);
[tf, idx] = strmatch('trial1', fieldnames(Data));
set(linehandles(idx), 'Color', 'r');
structfun(@(z) plot(z, 'r'), Data)
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com