How can I print variables within a function?
Mostrar comentarios más antiguos
Good day to all,
1st time posting here so I apologize for any errors. I am currently working on a script which uses the mat2tiles script. Essentially when the data is analyzed a variable called number_of_segments which can vary based on the size of data is created. This value is created by my script and can range from 1 to 1000. From this point I use the following code (which works)
% code
for i = 1:number_of_segments;
s=['Seg' int2str(i) '= mean(bandpower(data3{i,1},sampling_rate,[low_delta,high_delta;low_theta,high_theta;low_alpha1,high_alpha1;low_alpha2,high_alpha2;low_beta1,high_beta1;low_beta2,high_beta2,low_beta3,high_beta3;low_gamma,high_gamma],1,1))'];
eval(s);
end
This creates several variables which are named Seg1 to SegX where X is defined by the variable number_of_segments. Each Seg1 to SegX file is a 1x152 double array. My goal is to automatically concatenate these Seg1 to SegX arrays into one larger array which I have called TotalSegments.
I can do this by hand in the Command Window. For example if I know that number_of_segments = 5 then in order to get my desired result the code would be (this code works)
% code
TotalSegments=vertcat(Seg1,Seg2,Seg3,Seg4,Seg5);
end
The problem is that the variable number_of_segments changes for each file. I would like the script to output my result. My issue is that I do not know how to print this in MatLab. Here is what I have attempted (This code does NOT work)
% code
for i = 1:number_of_segments;
s=[int2str(i) 'TotalSegments= vertcat(Seg(i));'];
eval(s);
end
Does anyone know how this might be achieved? I appreciate any input. Thank You
Currently using MatLab R2014a
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!