Re: can we vectorize this
- From: helper <spam@xxxxxxxxxx>
- Date: Fri, 31 Mar 2006 10:31:01 -0500
vihang wrote:
set(h(handle_ind),'cdatamapping','scaled','facecolor','texture','cda
Hello
This is from the user contributed file found here
<http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4927&objectType=file>.
A part of the code is shown below.
I need to know whether this could be vectorised, so that it could
run
faster and be more memory efficient.
% Create y-slice
if (ind==2 || is3DTexture)
x = [model.xdata(1), model.xdata(1); model.xdata(2),
model.xdata(2)];
y = [model.ydata(1), model.ydata(1); model.ydata(1),
model.ydata(1)];
z = [model.zdata(1), model.zdata(2); model.zdata(1),
model.zdata(2)];
diff = model.ydata(2)-model.ydata(1);
delta = diff/size(cdata,1);
for n = 1:size(cdata,1)
slice = double(squeeze(cdata(n,:,:)));
h(handle_ind) = surface(x,y,z,'Parent',ax);
ta'edgealpha',0,'alphadata',double(slice),'facealpha','texturemap','ta
',slice,...
g'
,'vol3d');
y = y + delta;
handle_ind = handle_ind + 1;
end
end
%%%%%%%%%
Thanks and regards
Vihang
Vectorizing code can often be SLOWER and LESS memory efficient than
FOR loops. Without digging too far, I can assume Joe (MathWorks
employee) is fully aware of this and knows when/how to vectorize.
I suggest emailing Joe through his author link and asking if he has
any suggestions on how to speed his code.
.
- Follow-Ups:
- Re: can we vectorize this
- From: Jérôme
- Re: can we vectorize this
- References:
- can we vectorize this
- From: vihang
- can we vectorize this
- Prev by Date: Re: TMW please, hadn't we have enough of this spam
- Next by Date: Re: TMW please, hadn't we have enough of this spam
- Previous by thread: can we vectorize this
- Next by thread: Re: can we vectorize this
- Index(es):