how to convert from functions to matrix?

15 views (last 30 days)
I hope to make matrix about functions such as y=sinx
In other words, y=sinx functions' graph will be corresponded to m x n matrix.
For example, when I have a 300 x 200 matrix with a origin of (150,1), I want to call the value of the path through which the sin function passes in this matrix one.
how to do it?
Thanks
  3 Comments
kisik KIM
kisik KIM on 11 Sep 2020
i mean that i want to project each point on the graph from a 300x200 zeros matrix.
Let the origin is (150,1). So the value of this point will be one. Next, (151,2) will be one, ...

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 11 Sep 2020
Edited: Ameer Hamza on 11 Sep 2020
Are you trying to do something like this
M = zeros(300, 500);
cols = 1:size(M,2);
rows = floor(150-100*sin(cols/10));
idx = sub2ind(size(M), rows, cols);
M(idx) = 1;
imshow(M)

More Answers (0)

Categories

Find more on Graph and Network Algorithms 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!