I know there's a lot of questions on this problem but I can't find anything which quite works the way I'd like it to. I have a set of upper and lower bounds in spherical coordinates which as a pair each describe some small volume region. The result is 3 matrices R, Theta, Phi of size [Ntheta x Nphi x Nr] for both the upper and lower bounds. Corresponding to these individual bounds is then some scalar value in another matrix of size [Ntheta x Nphi x Nr].
What I would like to do is plot the individual volume elements i.e from [Tlow:Tup , Plow:Pup , Rlow : Rup] as filled blocks with color chosen by the value in the matrix. Some example code for the data I'm working with is given though these are just simplified pieces of data (I'm aware I can vectorise the for loops but again this is just example data):
Nr=3; Nt=20; Np=20;
Rq = linspace(0,1,Nr); Thetaq = linspace(0,pi,Nt); Phiq = linspace(-pi,pi,Np);
[Thetaq,Phiq,Rq] = meshgrid(Thetaq,Phiq,Rq);
delR = (max(Rq(:))-min(Rq(:)))./Nr;
delT = (max(Thetaq(:))-min(Thetaq(:)))./Nt;
delP = (max(Phiq(:))-min(Phiq(:)))./Np;
for Rind = 1:Nr
for Tind = 1:Nt
for Pind = 1:Np
Rlow(Tind,Pind,Rind) = delR.*(Rind-1); Rup(Tind,Pind,Rind) = delR.*Rind;
Tlow(Tind,Pind,Rind) = delT.*(Tind-1); Tup(Tind,Pind,Rind) = delT.*Tind;
Plow(Tind,Pind,Rind) = delP.*(Pind-1); Pup(Tind,Pind,Rind) = delP.*Pind;
mockobjprop = ones(Nt,Np,Nr);
mockobjprop(:,:,1:2) = 10;
The object I envisage here is a spherical object with 3 radial shells, such all volume elements in the inner two shells will have one colour and the 3rd shell will be a different colour. I'm hoping to utalise matlabs inbuilt colormaps as the general data is much more complicated than this two colour scheme. I have seen a few suggestions using the slice function however even if I convert my volume bounds to cartesian it finds the data to be defined on an invalid meshgrid.
The best solution I have so far is using a point at the centre of each volume chunk, converting to cartesian and plotting a scatter3 plot with the color set by the propety matrix. However visually this is appalling at best.
Xq = Rq.*sin(Thetaq).*cos(Phiq); Yq = Rq.*sin(Phiq).*sin(Thetaq); Zq =Rq.*cos(Thetaq);
Any advise or suggestions would be greatly appreciated. Even if it isn't exactly what I'm searching for anything would be an improvement. I had one suggestion of exporting the data to paraviewer however I cannot figure out how to export this type of data mind render it within paraviewer.