필터 지우기
필터 지우기

creating table in matlab of elliptic curve points

조회 수: 2 (최근 30일)
Muhammad Sohail Abid
Muhammad Sohail Abid 2018년 7월 11일
댓글: Walter Roberson 2018년 7월 13일
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
Steven Lord
Steven Lord 2018년 7월 11일
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 2018년 7월 12일
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])

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 7월 12일
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
Muhammad Sohail Abid
Muhammad Sohail Abid 2018년 7월 12일
this error arises can you please help me to fix this reshaping
Walter Roberson
Walter Roberson 2018년 7월 13일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by