Info
This question is closed. Reopen it to edit or answer.
I get an error for rxy[D]=0. I do not know why. Im doing a code for correlation.
1 view (last 30 days)
Show older comments
double x[100];
double y[100];
double rxy[100];
for D = 0:1:100
rxy [D]= 0
for n=0:1:99
rxy [D] = rxy[D]+x[n]*y[n-D]
end
2 Comments
Stephen23
on 13 Oct 2015
Edited: Stephen23
on 13 Oct 2015
This is not MATLAB code.
MATLAB does not use square brackets for indexing and is a dynamically typed language so does not use variable declarations. MATLAB also uses mathematical indexing (starting from one, not zero).
All of these things are covered quite well in every course for MATLAB beginners.
If you write code for another language and try to run it in MATLAB then your should expect errors. These tutorials are a good place to learn MATLAB:
Walter Roberson
on 13 Oct 2015
The variable declarations won't actually give an error, they just don't do anything close to declaring a variable.
Answers (1)
Walter Roberson
on 13 Oct 2015
Edited: Walter Roberson
on 13 Oct 2015
Matlab does not use square brackets for indexing..
Also indexing starts from 1
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!