from workspace to MATLAB FUNCTION BLOCK in simulink unable to fetch data in scope

3 visualizaciones (últimos 30 días)
i have a variable name A in Workspace containing time and data value,as this data with time or anything..i am trying this in my MATLAB Function block,I unable to get data value after simulation in scope..as this i tried in basic only.
error is coming invalid matrix variable ,asking time and data value both,i given both ,still getting error.
can anyone help....

Respuestas (1)

Abhas
Abhas el 1 de Ag. de 2024
Hi Sangeeta,
For importing data from the MATLAB Workspace, processing it using a MATLAB Function Block, and visualizing it using a Scope Block, follow the steps below:
  • Define the Variable in MATLAB Workspace:
% Example data
time = 0:0.1:10; % Time vector from 0 to 10 seconds with 0.1s intervals
data = sin(time); % Example data, sine wave
A = [time' data']; % Combine time and data into a single matrix
  • Create a Simulink Model: Add and Configure a "From Workspace Block" and set the "Data" parameter to variable "A".
  • Add and Configure a MATLAB Function Block:
function y = processData(u)
% Example processing: Just pass the input through
y = u;
end
  • Add a Scope Block: Connect the output of the "From Workspace" block to the input of the "MATLAB Function" block and the output of the "MATLAB Function" block to the input of the "Scope" block..
You may refer to the following MathWorks documentation link to have a better understanding on "From Worspace" block: https://www.mathworks.com/help/simulink/slref/fromworkspace.html

Categorías

Más información sobre Simulink Functions 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!

Translated by