for loop, indexing issues, and graph conversion to binary matrix
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hey i'm required replicating the following image in matlab through the use of matrices and the command 'imshow'. It needs to be a matrix of 501x 501, i started of with creating a zero matrix through the command (zeros(501)). Then added sections to it. I ended up getting the cirle in to the matrix but i cant work out away to get the curves in. The equation for the curve is x = [-250:250]; y = x.^3 / 62500;. I have tried to achieve this through the following command where extH being the matrix, without the circle because im trying to focus on the curve.
extH= zeros(501);
for x = [-250:250];
y = x.^3 / 62500;
extH(1:501, y)=1;
end
imshow(extH)
This did not work as it displayed the following message 'Subscript indices must either be real positive integers or logicals'. If anyone know how to solve this issue or know a better way to achieve this image please help.
Answers (1)
Azzi Abdelmalek
on 27 Mar 2016
% This is correct
extH= zeros(501);
x = -250:250;
y = x.^3 / 62500;
The problem is this line
extH(1:501,y)=1;
y is used as index, but it should be a positive integer
1 Comment
Michael Brady
on 27 Mar 2016
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!