Plotting Cells from a Cell array in order to create a raster plot. Please Help

1 visualización (últimos 30 días)
I am having trouble with plotting the cells from a cell array. The array has 158 cells of varying sizes and i wish to plot them on a raster plot with 8 different graphs. So far I have :
for i = 1:8
indDir1 = find(direction==1);
indDir2 = find(direction==2);
indDir3 = find(direction==3);
indDir4 = find(direction==4);
indDir5 = find(direction==5);
indDir6 = find(direction==6);
indDir7 = find(direction==7);
indDir8 = find(direction==8);
indDir = [indDir1;indDir2;indDir3;indDir4;indDir5;indDir6;indDir7;indDir8];
numTrials = length(indDir);
subplot(3,3,graph(i));hold on; % this is all for the subplots..here is not the issue
for i = 1: size(instruction)
spiketimes{i} = num2cell(neuron1.times(neuron1.times(:,1) >= instruction1sb(i) &
neuron1.times(:,1) < instruction1sa(i)))
end; % This is how i created the cell array with 158 cells for each trial
for j = [1:numTrials];
n = length(spiketimes);
% Here is where I have no idea how to plot these cells
plot([spiketimes ;spiketimes ], [ones(n,1)*j-1; ones(n,1)*j]);
end;
end;
Please help!!!
  3 comentarios
Geoff Hayes
Geoff Hayes el 22 de Mzo. de 2015
Shane - if you step through the code (using the debugger) what can you tell us about spiketeimes? How many elements are in this array - 158? What are you attempting to do with
plot([spiketimes ;spiketimes ], [ones(n,1)*j-1; ones(n,1)*j]);
I don't understand why you are concatenating spiketimes with itself and then repeating this for each trial. What are you attempting to do with the ones(n,1)*j-1? What does this mean?
Shane Hagen
Shane Hagen el 22 de Mzo. de 2015
Editada: Shane Hagen el 22 de Mzo. de 2015
I have moved forward with this:
for j = 1:158
n = length(spiketimes);
ix=cellfun(@isempty,spiketimes);
spiketimes(ix)={0} ;
for ii = [4,16,20,32,36,89,111,119,129,156] % Here I turned NaN values to 0 then into an empty cell
a = spiketimes {ii}; if a==0 spiketimes{ii} = cell{1};
end
end
%n = length(results(j,:));
%result(j) = spiketimes{j}; % not sure ifll end up needing these
line([spiketimes{j,1} ; spiketimes{j,1}],[ones(1,n)*j-1;ones(1,n)*j],'k-');
end; end;
Error using line Conversion to double from cell is not possible. % This is the error im currently getting
PLease...anyone..I would really appreciate the help. I need to be able to plot this. Eventually im going to have to assign these plots for different direction but for now im just trying to get past plotting the cells

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by