How can I import a signal extracting function in a Simulink 'From Workspace'-block?

2 ビュー (過去 30 日間)
Pascal Mousel
Pascal Mousel 2015 年 6 月 3 日
コメント済み: Pascal Mousel 2015 年 6 月 3 日
Hello,
I'm working on a project where I have to import a signal to Simulink. I first need to build the Signal from a ".mat" file (here called "data"), this file contains two sets of values and two sets of times. For the purpose of extracting and creating a signal (here "s"), I created this little function ("fkt").
function [ s ] = fkt()
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
load('data.mat')
samples= 100000:105000 ;
t = [data1_time(samples)]';
x= [data1_val(samples)];
s.time= t;
s.signals.values = x;
s.signals.dimensions =2 ;
end
I used it as "Data" parameter for a 'From Workspace'-block in Simulink and connected it to a scope, to have a look at the signal I get. But I get the block error:
*Invalid setting in 'Project/From Workspace' for parameter 'VariableName'.
Error evaluating parameter 'VariableName' in 'Project/From Workspace'
Undefined variable "fkt" or class "fkt.m".*
What am I doing wrong? I tried some stuff but I'm not getting where my mistake is. :-(
Thank you in advance :)
Best regards,
Pascal

回答 (1 件)

Ilham Hardy
Ilham Hardy 2015 年 6 月 3 日
The From Workspace block looks for Data (s) instead of script (fkt.m).
What happen if you put s instead if fkt/fkt.m in the Data parameter?
  1 件のコメント
Pascal Mousel
Pascal Mousel 2015 年 6 月 3 日
Thank you for your response! But I already tried that, in that case I get a different error:
Invalid structure-format variable specified as workspace input in 'BA/From Workspace'. The structure's 'dimensions' field must be a scalar or a vector with 2 elements. In addition, this field must be compatible with the dimensions of input signal stored in the 'values' field.
But since my dimensions are a scalar and I have two dimensions I don't get that error either... Or am I missing something? :/

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

カテゴリ

Help Center および File ExchangeSignal Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by