serialport​のプロパティ名を教え​てください。

1 visualización (últimos 30 días)
豪人
豪人 el 7 de Jun. de 2024
Comentada: 豪人 el 13 de Jun. de 2024
classdef MyApp2 < matlab.apps.AppBase
properties (Access = public)
UIFigure matlab.ui.Figure
end
end
のように
properties (Access = public)
Serialport1 ??????
end
としたいのですが、何かわかりません
どなたかお願いします

Respuesta aceptada

Vandit
Vandit el 10 de Jun. de 2024
Hello 豪人,
In MATLAB, when you are defining a property for a class such as a `SerialPort` object within a class definition, you don't specify the type of the property in the property block itself. Instead, you simply declare the property name, and its type will be determined by the value you assign to it.
If you are planning to use a 'SerialPort' object in your class, you can declare it in the properties block without specifying its type explicitly. Here's how you can declare a 'SerialPort' property within your class:
classdef MyApp2 < matlab.apps.AppBase
properties (Access = public)
UIFigure matlab.ui.Figure
SerialPort1 % No type is specified here
end
end
Later, when you instantiate or during the initialization of your 'MyApp2' class, you would typically assign an actual 'SerialPort' object to 'SerialPort1' like so:
self.SerialPort1 = serialport("COM3", 9600); % Creating a SerialPort object
In this example, 'serialport("COM3", 9600)' creates a 'SerialPort' object for communication with a device connected to COM3 at a baud rate of 9600, and assigns it to the 'SerialPort1' property of the class. The "serialport" function is used in MATLAB for creating a 'SerialPort' object for serial communication.
For more information on "serialport" function, please refer to the documentation below:
Hope this helps.
  1 comentario
豪人
豪人 el 13 de Jun. de 2024
Thank you for answering my question.
I really apriciate you.
Now, I have another probrem.
I want to look the workspace of serialport.
But in this case, I can't look Myapp2 information.
So I can't judge if my script(or classdef) is correct.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre ビッグ データの処理 en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!