Showing : At least one END is missing: the statement may begin here.

26 views (last 30 days)
Yulia M
Yulia M on 22 Feb 2020
Commented: Yulia M on 22 Feb 2020
I am trying to run this code but getting the mentioned error:
I tried to indent the code with smart ident but it is not working either! solution suggested for this kind of error.
rng (42);
s = randi ([0, 3], 1, 100000);
dlmwrite ( 'random_4.txt' , s, ',' );
rng (42);
s = randi ([0, 1], 1, 100000);
dlmwrite ( 'random_1.txt' , s, ',' );
rng (42 * 42);
s = randn (1, 100000);
dlmwrite ( 'randn_seed4242.txt' , s, ',' );
>> create_random_data
Error: File: rng.m Line: 6 Column: 1
At least one END is missing: the statement may begin here.
Error in create_random_data (line 3)
rng (42);
  6 Comments
Yulia M
Yulia M on 22 Feb 2020
@jacob Wood thank you it was the problem you specified it helped me a lot.

Sign in to comment.

Answers (1)

the cyclist
the cyclist on 22 Feb 2020
Edited: the cyclist on 22 Feb 2020
The last line of rng.m is
endfunction
but it should be just
end
I also spotted another problem, which is that you should have
end % this is correct MATLAB syntax
instead of
endif % this is not correct MATLAB syntax
You are then going to encounter a new error:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in rng (line 4)
state = [state_n, state_i];
Error in create_random_data (line 3)
rng(42);
but it is not perfectly clear to me what you are trying to do there, so I suggest you try to solve that one on your own, and post a new question if you get stuck.

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!