creating table in matlab of elliptic curve points

2 views (last 30 days)
I get the points of elliptic curve and then when I try to convert that 1D array into 2D and try to make a table some error appears need help here is an example of code
if true
% code
end
disp('y^2 = x^3 + 5376x + 2438 mod 123457')
a=0:123456
left_side = mod(a.^2,123457);
right_side = mod(a.^3+5376*a+2438,123457);
points = [];
for i = 1:length(right_side)
I = find(left_side == right_side(i));
for j=1:length(I)
points = [points;a(i),a(I(j))];
end
end
plot(points(:,1),points(:,2),'ro')
set(gca,'XTick',0:1:123456)
set(gca,'YTick',0:1:123456)
grid on;
Z=reshape(points,[256,482])
  2 Comments
Steven Lord
Steven Lord on 11 Jul 2018
What is the full text of the error message you receive when you run that code, and on which line does the error occur? Show us all the text displayed in red (and if you receive any warnings in orange, show us the full text of those warning messages as well.)
Muhammad Sohail Abid
Muhammad Sohail Abid on 12 Jul 2018
this text appears
if true
% code
end
Error using reshape
To RESHAPE the number of elements must not change.
Error in ECPoint (line 16)
Z=reshape(points,[256,482])

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 12 Jul 2018
You are asking to reshape a 123387 by 2 array into a 256 x 482 array. The number of elements in the array is not divisible by 256 or 482 -- it is just slightly less than 482 * 256 * 2
  6 Comments
Muhammad Sohail Abid
Muhammad Sohail Abid on 12 Jul 2018
this error arises can you please help me to fix this reshaping
Walter Roberson
Walter Roberson on 13 Jul 2018
Sorry, I cannot seem to find words that make it sufficiently clear to you that you have 256 times 482 times 2 data points that you are trying to reshape into a 256 times 482 times 1 array.
Imagine that you have an array
A B
C D
E F
G H
I J
K L
and you ask to reshape() it to be a 3 x 2 array. Now, the number of rows you have is 6, and 6 is 3 x 2, so you think you should be able to do the reshape. But you cannot do that, because the 3 x 2 array you would end up would have only 6 total entries, but the 6 x 2 array that you start with has 12 total entries. You cannot make a 3 x 2 array out of the 6 x 2 array except by throwing away half of the data.

Sign in to comment.

More Answers (0)

Categories

Find more on Special Functions 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!