How to do: Multiple Row Allocation within a for loop for a Variable in GF (2^m)

조회 수: 1 (최근 30일)
Hello all,
Recently, I started working on a ECC implementation in Matlab to model the ECDH (elliptic curve diffie-hellman key exchange) algorithm. Everything was going great until I wanted to allocate each point on the curve starting from my base point i.e. P1 (base), P2, P3, P4, ... etc. I thought that a simple for loop would do the trick like this...
m = 9;
x1=6;
y1=298;
% Input GF allocation for EC in GF(2^m) --> first point (Base point)
x0 = gf(x1,m);
y0 = gf(y1,m);
A = [x0,y0] % 'A' is to show that without a for loop, the allocation works as expected and shown in the output
for i = 1 : 2 % Test loop, in my code I have while 1 and a break to work with the rest of my code accordingly
if i == 1
B(i) = [x0,y0] % <------------'B(i)' won't allocate correctly
end
end
But to my surprise I was stuck with the following error... I don't know if this is a problem with the internal Matlab function gf() or if there is a specific way to do this allocation. I cannot allocate each point by brute-force because there will be MANY points, therefore I need to use a loop.
I want to thank you in advance for your time, explanation, and efforts in helping me tackle this problem I am facing; have a fantastic day!
- Dylan R.
  댓글 수: 2
Walter Roberson
Walter Roberson 2015년 11월 13일
Has B been given a value before that point, or is it undefined at the time the problem occurs?
lalonded
lalonded 2015년 11월 13일
B hasn't been defined or given a value before that point. It is just a arbitrary variable to help illustrate my problem. Thanks for commenting!

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

채택된 답변

Thorsten
Thorsten 2015년 11월 13일
I would guess that the following works
B{i} = [x0, y0];
  댓글 수: 3
Thorsten
Thorsten 2015년 11월 16일
B(i) can just store a single element, but not two, [x0, y0];
B(i,:) = [x0, y0]
may also work, if x0 and y0 have the same size for each i.
RESHMA
RESHMA 2017년 1월 17일
can you please suggest me to encrypt an image using matlab

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Error Detection and Correction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by