How to covert char to param.Continuous for optimization?

The sim command encountered an error when setting the model parameter value defined by the parameter object 'model:StopTime', the error was: 'Cannot convert from 'char' to 'param.Continuous'.'.

8 Commenti

I have no idea what you are talking about. Please be clearer.
RK
RK il 31 Ago 2017
Modificato: RK il 31 Ago 2017
When I run this code, I get the error mentioned above. How to resolve it?
load tempSI2hk.txt;
te=tempSI2hk; %All data new name
ste=size(te);
%plot chosen (* indicated) raw data
plot(te(:,1),te(:,2),te(:,1),te(:,3),te(:,1),te(:,4),te(:,1),te(:,5));
grid;
title('measurements: toa, thous, tw/hous, tw');
xlabel('time [s]');
ylabel('temperature [Co]');
pause;
te=te(2:ste(1),:);%cutting off of first data points
ste=size(te);
tte1=te(:,1)-58;%time scale modification
% plot(tte1,te(:,3),tte1,te(:,5));
% grid;
% title('measurements: thous, tw');
% xlabel('time [s]');
% ylabel('temperature [Co]');
% pause;
plot(tte1,te(:,5));
grid;
title('measurements: tw');
xlabel('time [s]');
ylabel('temperature [Co]');
pause;
%variables defined in the model workspace (manually find)
toa=te(1,5); %initial temperature (from experiment)
gswoa=2.4; %2.53 thermal conductivity
psw=100; %thermal power
csw=35; %thermal capacitance
%parameter passed to simulation
%parameters to be modified [gswsc,csw]
%constant parameters [toa,psw]
open_system('model'); %opening "one body thermal model"
%creating an experiment object for IM heating
heating=sdo.Experiment('model');
%creating an object to specify temperature output data
TempSig=Simulink.SimulationData.Signal;
TempSig.Name='teta1';
%TempSig.BlockPath='model';
TempSig.Values=timeseries(te(:,5),tte1);
%adding the temperature signal to the heating experiment as the expected
%output data
heating.OutputData=TempSig;
%specifying initial temperature and heat power
toa=sdo.getParameterFromModel('model',{'toa'});
toa.Value=te(1,5); %initial temperature (from experiment)
toa.Free=false; %will not change
psw=sdo.getParameterFromModel('model',{'psw'});
psw.Value=100;
psw.Free=false; %will not change
%not known parameters (gswoa, csw)
gswoa=sdo.getParameterFromModel('model',{'gswoa'});
gswoa.Free=true;
gswoa.Minimum=0;
csw=sdo.getParameterFromModel('model',{'csw'});
csw.Free=true;
csw.Minimum=0;
%adding "toa", "psw", "gswoa", "csw" parameters to the experiment
heating.Parameters=[toa;psw;gswoa;csw];
%creating simulation scenario
Simulator=createSimulator(heating);
Simulator=sim(Simulator);
%searching for temperature signal in the logged simulation data
SimLog=find(simulator.LoggedData,get_param('model','SignalLoggingName'));
teta1=find(SimLog,'teta1');
plot(tte1,te(:,5),teta1.Values.Time,teta1.Values.Data);
grid;
title('measurements and simulation: tw');
xlabel('time [s]');
ylabel('temperature [Co]');
pause;
Also please select the code you pasted and click on the {} Code button.
Please use the "{} Code" button to make the code readable. Don't you see that its formatting is ugly?
I cannot see where "the following error" is mentioned. Please post the complete error message. Give the readers a chance to help you.
load tempSI2hk.txt;
te=tempSI2hk; %All data new name
ste=size(te);
%plot chosen (* indicated) raw data
plot(te(:,1),te(:,2),te(:,1),te(:,3),te(:,1),te(:,4),te(:,1),te(:,5));
grid;
title('measurements: toa, thous, tw/hous, tw');
xlabel('time [s]');
ylabel('temperature [Co]');
pause;
te=te(2:ste(1),:);%cutting off of first data points
ste=size(te);
tte1=te(:,1)-58;%time scale modification
% plot(tte1,te(:,3),tte1,te(:,5));
% grid;
% title('measurements: thous, tw');
% xlabel('time [s]');
% ylabel('temperature [Co]');
% pause;
plot(tte1,te(:,5));
grid;
title('measurements: tw');
xlabel('time [s]');
ylabel('temperature [Co]');
pause;
%variables defined in the model workspace (manually find)
toa=te(1,5); %initial temperature (from experiment)
gswoa=2.4; %2.53 thermal conductivity
psw=100; %thermal power
csw=35; %thermal capacitance
%parameter passed to simulation
%parameters to be modified [gswsc,csw]
%constant parameters [toa,psw]
open_system('model'); %opening "one body thermal model"
%creating an experiment object for IM heating
heating=sdo.Experiment('model');
%creating an object to specify temperature output data
TempSig=Simulink.SimulationData.Signal;
TempSig.Name='teta1';
%TempSig.BlockPath='model';
TempSig.Values=timeseries(te(:,5),tte1);
%adding the temperature signal to the heating experiment as the expected
%output data
heating.OutputData=TempSig;
%specifying initial temperature and heat power
toa=sdo.getParameterFromModel('model',{'toa'});
toa.Value=te(1,5); %initial temperature (from experiment)
toa.Free=false; %will not change
psw=sdo.getParameterFromModel('model',{'psw'});
psw.Value=100;
psw.Free=false; %will not change
%not known parameters (gswoa, csw)
gswoa=sdo.getParameterFromModel('model',{'gswoa'});
gswoa.Free=true;
gswoa.Minimum=0;
csw=sdo.getParameterFromModel('model',{'csw'});
csw.Free=true;
csw.Minimum=0;
%adding "toa", "psw", "gswoa", "csw" parameters to the experiment
heating.Parameters=[toa;psw;gswoa;csw];
%creating simulation scenario
Simulator=createSimulator(heating);
Simulator=sim(Simulator);
%searching for temperature signal in the logged simulation data
SimLog=find(simulator.LoggedData,get_param('model','SignalLoggingName'));
teta1=find(SimLog,'teta1');
plot(tte1,te(:,5),teta1.Values.Time,teta1.Values.Data);
grid;
title('measurements and simulation: tw');
xlabel('time [s]');
ylabel('temperature [Co]');
pause;
The error is : The sim command encountered an error when setting the model parameter value defined by the parameter object 'model:StopTime', the error was: 'Cannot convert from 'char' to 'param.Continuous'.'.
Have you tried using the debugger?
Which is the offending line? I, for one, don't feel like trudging to your code and you have not provided the data that would allow us to run it.
Here is the data and model attached.
KL
KL il 31 Ago 2017
Modificato: KL il 31 Ago 2017
I haven't run your model too but just searching the term "param.Continuous" takes me to
Probably you're making a mistake either in those lines where you change the Free and Minimum property or
heating.Parameters=[toa;psw;gswoa;csw];
in this line altogether. Read more about the experiment class maybe

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Simulink Design Optimization in Centro assistenza e File Exchange

Prodotti

Richiesto:

RK
il 30 Ago 2017

Modificato:

KL
il 31 Ago 2017

Community Treasure Hunt

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

Start Hunting!

Translated by