SAME VALUE ON EVERY LOOP...

16 次查看(过去 30 天)
diala yazbeck
diala yazbeck 2020-10-2
评论: VBBV 2020-10-2
HI EVERYONE. need some help here...
my code is giving me the same output on every run and no matter what im doing, its giving me the same output.
here is a snippet of whats going on.
data = 2;
point = [1 2 3 ;
4 7 8 ; ]; %% for point clouf.
ptcloud = pointCloud(centroidlocation);
radius = 15;
lesion = 5;
for p =1: data
temp_point = point(p,:);
% Get the indices and the distances of points that lie within the specified radius
[indices,dists] = findNeighborsInRadius(ptcloud,temp_point,radius);
ptcloudB = select(ptcloud,indices);
indices_1 = length(indices);
% change material properties of lesion
for i=1:indices_1
t_id = elem_e(:);
t_id(indices)= lesion;
end
% do whatever for point
% multiple loops to find stuff
file_name (p) = min (whatever);
file_name_2(p) = min (whatever2);
file_name_3 (p) = min (whatever3)
end
help please!!!!
  3 个评论
diala yazbeck
diala yazbeck 2020-10-2
编辑:diala yazbeck 2020-10-2
is the file_name(p) correct or should it be file_name(p,:),
also im still getting the same output...
VBBV
VBBV 2020-10-2
%if true
% code
% end
% change material properties of lesion
for i=1:indices_1
t_id = elem_e(:);
t_id(i)= lesion;
end
Try the loop index in t_id.

请先登录,再进行评论。

回答(1 个)

Steve Eddins
Steve Eddins 2020-10-2
This loop in your code looks suspicious to me:
% change material properties of lesion
for i=1:indices_1
t_id = elem_e(:);
t_id(indices)= lesion;
end
Perhaps I am misunderstanding something, but it looks like t_id will be unchanged after the first iteration through the loop body. Is there a programming error here?
If you haven't done this already, then I recommend that you try using the debugger. Set a breakpoint at the beginning of the code, then execute it. Single-step through each line of the code, pausing to inspect the values of variables that just got changed. See if the values are what you expect. In case you are not familiar with the debugger, here is a documentation link.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by