Error when executing an existing code

1 回表示 (過去 30 日間)
Daniel Pochapski Pochapski
Daniel Pochapski Pochapski 2022 年 3 月 28 日
回答済み: Jan 2022 年 3 月 29 日
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 件のコメント
Jan
Jan 2022 年 3 月 28 日
You forgot to mention, which problems you have with the code.
Daniel Pochapski Pochapski
Daniel Pochapski Pochapski 2022 年 3 月 28 日
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.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2022 年 3 月 29 日
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.

カテゴリ

Help Center および File ExchangeUsing MATLAB Projects in Simulink についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by