Error when executing an existing code

Hello guys,
I'm a new Matlab user, and I'm having some problems running code copied directly from a reference. There are several errors and observations in the model, which is quite extensive, by the way. Although the problems in the code seem to me to be quite broad, I would like to know how I can correctly check each error indicated? I have attached a .m file containing the code.
The reference from where I copied the code is at the end of the text at: https://digitalcommons.usf.edu/cgi/viewcontent.cgi?article=2440&context=etd

3 Comments

But what you don't say is what are the errors that you got.
The odds are good you don't have some necessary toolboxes. Or possibly, that you just don't understand how to use or interact with the code you got.
So show what you did. Show what was the error. The COMPLETE error, so everything in red.
You forgot to mention, which problems you have with the code.
Various errors like:
Error: File: Untitled27.m Line: 1380 Column: 3
Unexpected MATLAB operator.
(referent to: "function ret=arc2(r1,r2,h,phi)")
Error: File: Untitled27.m Line: 1651 Column: 1
Unterminated %{ block. Use %} to terminate.
Every time I try to run the code, similar errors pop up. I've attached the code above if you can/want to check it out.

Sign in to comment.

Answers (1)

Error: File: Untitled27.m Line: 1380 Column: 3
Unexpected MATLAB operator.
(referent to: "function ret=arc2(r1,r2,h,phi)")
At this location the code is
arc2.m
function ret=arc2(r1,r2,h,phi)
The actual problem is "arc2.m" . This looks like it should be the name of the m file, not a part of the code. So create an m file called "arc2.m" and insert the following code.
This problem occurs repeatedly, e.g. line 2288:
eucnorm.m (Originally written by E. Marquez (1994), modified by C. OBrien (2003))
function ret=eucnorm(n,z)
The first line should not be a part of the code!
By the way, this is an ugly implementation of a euklidean norm.
Error: File: Untitled27.m Line: 1651 Column: 1
Unterminated %{ block. Use %} to terminate.
There is a bunch of nested %{ %} commant blocks. This is not allowed. The person, who has created this muddy code is the one, who can provide a celan version. It is impossible to guess, which comment blocks are wanted and which are defined by accident.
The code is useless, as you have found out already. Do not try to solve a real problem with it. The debugging and fixing will take more time than deleting and rewriting the code in a clean way.

Categories

Find more on Using MATLAB Projects in Simulink in Help Center and File Exchange

Products

Release

R2021a

Answered:

Jan
on 29 Mar 2022

Community Treasure Hunt

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

Start Hunting!