Search code examples
matlabplot3dmatlab-figure

volumetric slice plot gone wrong


Here is my code:

xslice = [bestcoefs(1), cc1(no1)]; 
yslice = [bestcoefs(2), cc2(no2)];
zslice = [cc3(1), bestcoefs(3)]; 
slice(V, xslice, yslice, zslice, 'linear');
cb = colorbar; 
xlabel('c1'); ylabel('c2'); zlabel({'likelihood of (c1,c2,c3)','c3'});
view(3);

V is a matrix of probabilities 6x13x9 and bestcoefs(1), cc1(no1), etc. are points where I want to slice the plot. However, I get this result:

wrong

Why does it come out like this? I want it to look like the first one here.


Solution

  • When I run:

    % some data:
    V = randn(6,13,9);
    bestcoefs = randi(6,3,1);
    cc = randi(6,3,1);
    
    % your code with slight modifications:
    xslice = [bestcoefs(1), cc(1)]; 
    yslice = [bestcoefs(2), cc(2)];
    zslice = [cc(1), bestcoefs(3)]; 
    slice(V, xslice, yslice, zslice, 'linear');
    cb = colorbar; 
    xlabel('c1'); ylabel('c2');...
        zlabel({'likelihood of (c1,c2,c3)','c3'});
    view(3);
    

    I get something like this:

    enter image description here

    Which looks fine to me. Try to see if your bestcoefs, cc's and no's are defined correctly.