Problem with indices (Subscript indices must either be real positive integers or logicals)
Show older comments
I have a matrix with 3 indices (MxNxP) containing all doubles. The first two columns of any page give the x and y coordinates for that iteration (of each ray reflecting off mirrors). I use a square grid of starting points and then use "scatter" to plot the entry points on one chart and the exit points on another chart and everything works fine with this code:
figure
scatter(rays(:,1,1),rays(:,2,1),'*')
axis equal
title('All Ray Entry Points')
HOWEVER, if I add some amount of random +/- scatter to the original starting grid points with the following code by setting add_scatter=true:
if add_scatter == true
scatter = rand(M,2);
scatter(:,:) = scatter(:,:) - 0.5;
scatter(:,:) = scatter(:,:)*spacing*0.5;
rays(:,1:2) = rays(:,1:2) + scatter(:,:);
end
the scatter plot code returns the following error for every graph: "Subscript indices must either be real positive integers or logicals"
The matrix "rays" is still the same size and still contains only doubles. I can use the command window to see any location by putting any 3 index values in (e.g. rays(5,2,1)) but cannot generate any figures with the scatter plot function.
Any ideas???
Accepted Answer
More Answers (1)
C Wing
on 4 Mar 2015
0 votes
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!