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

12 Ansichten (letzte 30 Tage)
Talal
Talal am 29 Jan. 2012
Beantwortet: Rinku Kumar am 31 Okt. 2018
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 Kommentar
Walter Roberson
Walter Roberson am 30 Jan. 2012
We need to see the call, and for any parameter passed in which is a variable, we need to know class() of that variable.

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Rina Blomberg
Rina Blomberg am 15 Mär. 2015
Bearbeitet: Rina Blomberg am 15 Mär. 2015
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 am 31 Okt. 2018
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 am 29 Nov. 2012
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

Kategorien

Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by