Error when executing an existing code

1 Ansicht (letzte 30 Tage)
Daniel Pochapski Pochapski
Daniel Pochapski Pochapski am 28 Mär. 2022
Beantwortet: Jan am 29 Mär. 2022
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 Kommentare
Jan
Jan am 28 Mär. 2022
You forgot to mention, which problems you have with the code.
Daniel Pochapski Pochapski
Daniel Pochapski Pochapski am 28 Mär. 2022
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 29 Mär. 2022
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.

Kategorien

Mehr zu Using MATLAB Projects in Simulink finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by