日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab from有什么用,Matlab函数使用'fromworkspace'将向量传递给simulink

發布時間:2024/9/27 循环神经网络 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab from有什么用,Matlab函数使用'fromworkspace'将向量传递给simulink 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我想編寫一個包含simulink塊的matlab函數 . 該函數應將數據加載到simulink模型中,運行它,然后從函數返回數據 .

我能想到的唯一方法就是在simulink中使用'To Workspace'和'From Workspace'塊 . 問題是'From Workspace'塊不從功能范圍中獲取變量,只從工作空間范圍中獲取變量 .

下面是我能想到的唯一解決方案,它基本上將傳入的向量轉換為字符串,然后創建一個在模型啟動時被調用的函數(實際上這與eval一樣糟糕) .

這是代碼:

function [ dataOut ] = run_simulink( dataIn )

% Convert data to a string (this is the part I would like to avoid)

variableInitString = sprintf('simin = %s;', mat2str(dataIn));

% we need both the name and the filename

modelName = 'programatic_simulink';

modelFileName = strcat(modelName,'.slx');

% load model (without displaying window)

load_system(modelFileName);

% Set the InitFcn to the god awful string

% this is how the dataIn actually gets into the model

set_param(modelName, 'InitFcn', variableInitString);

% run it

sim(modelName);

% explicity close without saving (0) because changing InitFcn

% counts as changing the model. Note that set_param also

% creates a .autosave file (which is deleted after close_system)

close_system(modelName, 0);

% return data from simOut that is created by simulink

dataOut = simout;

end

你運行它是這樣的: run_simulink([0 0.25 0.5 0.75; 1 2 3 4]') 矩陣的第一部分是時間向量 .

最后,這是底層的simulink文件,其工作區塊屬性打開以保證完整性 .

(如果圖像模糊,點擊放大)

如果沒有 mat2str() 和 sprintf() ,有沒有更簡潔的方法呢? sprint 行需要永遠運行,即使是大小為50k的向量也是如此 .

總結

以上是生活随笔為你收集整理的matlab from有什么用,Matlab函数使用'fromworkspace'将向量传递给simulink的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。