Using slice in a fuction and from command window
Afficher commentaires plus anciens
Hi everyone: I am using slice to display views of a Ultrasound created image volume. When I run it from the comman window I get the error of "Index exceeds matrix dimensions" but if I create a function in which I call slice and produce the cuts then it works. I have tried with simple examples like the one included in the description of the slice function usage and I get the same results. Being a the volume with dimensions (149x148x200):
-------------------------------------------
Command Window: sizevol=size(a);
% %slice and visualise cross sections for volume
[xgrid,ygrid,zgrid]=meshgrid(1:sizevol(2),1:sizevol(1),1:sizevol(3));
a=double(a);
h=slice(xgrid,ygrid,zgrid,a,100,100,10);
ERROR - Index exceeds matrix dimensions
-------------------------------------------
Function: slicefcn(a);
"""""
function slicefnc(V)
figure;
[x,y,z] = meshgrid(1:size(V,2),1:size(V,1),1:size(V,3));
hslices=slice(x,y,z,V,size(V,2)/2,size(V,1)/2,size(V,3)/2);%
colormap(gray);
xlabel('x');ylabel('y');zlabel('z');
end
""""
getting the desired result attached;
Has anyone an idea why this happens? am I missing or ignoring something? Cheers
Sergiusz
2 commentaires
Selva Karna
le 17 Août 2017
V1=magic(5); V(:,:,1)=V1 V(:,:,2)=V1 V(:,:,3)=V1 slicefnc(V)
function slicefnc(V) figure; [x,y,z] = meshgrid(1:size(V,2),1:size(V,1),1:size(V,3)); hslices=slice(x,y,z,V,size(V,2)/2,size(V,1)/2,size(V,3)/2);% colormap(gray); xlabel('x');ylabel('y');zlabel('z'); end

Sergio Morales
le 17 Août 2017
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!