Error: 'model' parameter must be a string."what should I do?!!!

12 ビュー (過去 30 日間)
Talal
Talal 2012 年 1 月 29 日
回答済み: Rinku Kumar 2018 年 10 月 31 日
Hello Everyone, I'm trying to reproduce some new data from a trained network and I'm getting this error: "??? Error using ==> forward_network at 12 'model' parameter must be a string." Please advise.
Thanks, TSM
[EDITED, copied from comments]
a = imread(filename);
b = rgb2gray(a);
glcmn1 = graycomatrix(b);
c = glcmn1 (:);
a = load ('Channel and Fault Recognition.mat');
sim (a, c);
I tried to load the neural network from folder and simulate it with the input "c", same error was occurred.
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 1 月 30 日
We need to see the call, and for any parameter passed in which is a variable, we need to know class() of that variable.

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

回答 (3 件)

Rina Blomberg
Rina Blomberg 2015 年 3 月 15 日
編集済み: Rina Blomberg 2015 年 3 月 15 日
My answer may not be related to this specific problem, but it may help anyone searching for this particular error message when attempting to use the function sim() after having saved and loaded a trained neural network.
The trained network is saved as a .mat file. Eg:
save([path 'net.mat'], 'net');
If for example, this network is then loaded in another script:
net = load([path 'net.mat']);
and then one attempts the follwing code:
results = net(testdata); or results = sim(net, testdata);
Then MATLAB outputs the following error (respective to the function used above): Subscript indices must either be real positive integers or logicals or 'model' parameter must be a string
The reason for the error in this particular scenario is because the network has been saved in a struct array. To access the network for simulation you must write: importvariablename.savedvariablename. For example, if using the variable names from above the network must be properly accessed by writing:
results = net.net(testdata); or results = sim(net.net, testdata);

Rinku Kumar
Rinku Kumar 2018 年 10 月 31 日
for the problem of error 'model' parameter must be a string....... sim command must include the quotes, for example
sim('Model name')
will consider the model parameter as a string...
very simple

Matt Fig
Matt Fig 2012 年 11 月 29 日
From the help (which you can read too!):
SimOut = sim('MODEL', PARAMETERS) simulates your Simulink model, where 'PARAMETERS' represents a list of parameter name-value pairs, a structure containing parameter settings, or a configuration set.
So, you are calling structure a (returned by LOAD) and the output from glcmn1. I suggest you read this and try to call the function correctly:
doc sim

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by