parse error and Directory error for class definition

2 ビュー (過去 30 日間)
Arsiv
Arsiv 2024 年 4 月 24 日
回答済み: Harald 2024 年 4 月 24 日
hey guys, in the below code, i am having 2 errors:
  • I cannot run the code due to this error: "A class definition must be in an "@" directory",
  • there is a "parse error usage might be invalid matlab syntax" at line "inputData"
  • the working folder in this case is : C:\Users\auto\Car@PC\Templates\@preprocessor
  • inside templates folder I have also other working .m scripts, but without any class definitions.
  • matlab verison R2015b
How to solve this issues?
Thankyou!
classdef preprocessor
properties
vehicleParameters
weatherConditions
roadDefinitions
maneuvers
faultInjections
end
methods
function obj = preprocessor(vehicleParams, weatherConds, roadDefs, maneuvers, faults)
if nargin > 0
obj.vehicleParameters = vehicleParams;
obj.weatherConditions = weatherConds;
obj.roadDefinitions = roadDefs;
obj.maneuvers = maneuvers;
obj.faultInjections = faults;
end
end
end
end
%% %% Define the structure containing all parameters and values
inputData = struct();
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.

採用された回答

Harald
Harald 2024 年 4 月 24 日
Hi,
how are you trying to run the code? Clicking the "run" button does not make sense, you need to call the constructor, e.g.
obj = preprocessor()
In a class file, there should generally be no other code. This is why you get the error regarding the inputdata line.
I would avoid having folder names like Car@PC that contain special characters for purpose, such as indicating class folders.
Best wishes,
Harald

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by