필터 지우기
필터 지우기

matrice problem in sim command

조회 수: 2 (최근 30일)
mehmed celebi
mehmed celebi 2015년 5월 17일
댓글: mehmed celebi 2015년 5월 18일
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);

답변 (1개)

Walter Roberson
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.
  댓글 수: 1
mehmed celebi
mehmed celebi 2015년 5월 18일
Thank you for your answer, but this is not the problem I wrote. I know the exact digit of the values. I make a matrice from real numbers. But when it was used by its name and location in the sim command, the results become different. I made something yesterday. I all copied the values of the matrice, and pasted and it works!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by