matrice problem in sim command
1 view (last 30 days)
Show older comments
Hi,
I have an extraordinary problem in simulink. I have a simulink mdl file. When I run this file from command line with sim command with a matrice name for ex: A(1,:), it gives a normal result. But when I copy the this matrice row and paste it in command line it gives another result!
(En_iyi2(5,1:5)) gives 0.45 and tracklsq3([1.5000 1.0800 0.6000 0.1200 0.5200]) gives 0.0407 , another result! Both of them is the same matrice. What is the solution. This is the tracklsq3 file:
function [yout] = tracklsq3(pid)
% Track the output of optsim to a signal of 1
% Variables a1 and a2 are shared with RUNTRACKLSQ
Kp = pid(1);
Ki = pid(2);
lambda = pid(3);
Kd = pid(4);
mu = pid(5);
simopt = simset('solver','ode23t','SrcWorkspace','Current','DstWorkspace','Current'); % Initialize sim options
[tout,xout,yout] = sim('mehmed5_48V_1kW',[0 .04],simopt);
0 Comments
Answers (1)
Walter Roberson
on 17 May 2015
You have a difference in rounding between the actual binary numbers and what is being displayed. Try using
format long g
disp(En_iyi2(5,1:5))
and your values will probably show up differently.
In some cases, the above is not enough to find the problem. If you are on Linux or OS-X but not MS-Windows then you can use
sprintf('%.399g\n', En_iyi2(5,1:5))
to see the entire number. If you are on MS-Windows then you will need something like James Tursa's num2strexact to view all of the digits.
See Also
Categories
Find more on Model Predictive Control Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!