matrice problem in sim command
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2015년 5월 17일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Model Predictive Control Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!