이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.
조회 수: 67 (최근 30일)
이전 댓글 표시
i was trying to make a predictive code algorithm however i recieve the same error every time .
code below.
function [Sa,Sb,Sc] = control(T_ref,sflux_ref,wm,i_meas)
% Variables defined in the parameters file
global Ts Rs Lr Lm Ls p tr kr r_sigma t_sigma lambda v states
persistent x_opt Fs %Fsp1 Tp1 g
if isempty(x_opt), x_opt = 1; end
if isempty(Fs), Fs = 0 + 0i*1; end
T_ref = T_ref(1) + 1j*T_ref(2);
sflux_ref = sflux_ref(1) + 1j*sflux(2);
i_meas = i_meas(1) + 1j*i_meas(2);
wm = wm(1) + 1j*wm(2);
% Stator flux estimate
Fs = Fs + Ts*(v(x_opt) - Rs*i_meas);
% Rotor flux estimate
Fr = Lr/Lm*Fs+i_meas*(Lm-Lr*Ls/Lm);
g_opt = 1e10;
for i = 1:8
% i-th voltage vector for current prediction
v_o1 = v(i);
% Stator flux prediction at instant k+1
Fsp1 = Fs + Ts*v_o1 - Rs*Ts*i_meas;
% Stator current prediction at instant k+1
Isp1 = (1+Ts/t_sigma)*i_meas+Ts/(t_sigma+Ts)*(1/r_sigma*((kr/tr-kr*1i*wm)*Fr+v_o1));
% Torque prediction at instant k+1
Tp1 = 3/2*p*imag(conj(Fsp1)*Isp1);
% Cost function
g = abs(T_ref - Tp1)+ lambda*abs(sflux_ref-abs(Fsp1));
if (g<g_opt)
g_opt = g;
x_opt = i;
end
end
댓글 수: 17
Walter Roberson
2022년 5월 19일
okay, and did you register each of the global variables as a datastore using the Port Manager?
amr makhlouf
2022년 5월 22일
i have tried couple of things one of which to use the data store memory block , and i have tried to register the variables in the port manager but it's not shown @Walter Roberso@Walter Roberson
Walter Roberson
2022년 5월 22일
You might be interested in my discussion at https://www.mathworks.com/matlabcentral/answers/1653710-global-variable-in-simulink#comment_2009495
amr makhlouf
2022년 5월 24일
i have read the full discussion over there but there are some point that i don't understand :-
1- where i shoud add the first part of the code starting from % Variables required by the control algorithm
% Sampling time of the predictive algorithm [s]
Ts_value = 4e-5; till
SS.InitialValue = mat2str(value);
end .. i quite belive this should be in the intial function call backs .
2- in the main function function [sa,sb,sc] = control(T_ref,sflux_ref,wm,i_meas,kr,Lm,p,r_sigma,t_sigma,tr) you have included multiple of inputs starting from Kr to tr which is not included in the refrence paramters from the induction motor paramters
Walter Roberson
2022년 5월 24일
That code all involved a specific model the user provided, in which that script was responsible for initializing variables and parameters, and then using sim() to run the model.
Adding additional parameters to the function was the cleanest way of importing Simulink parameters.
amr makhlouf
2022년 5월 24일
well fourtunately , am trying the same exact model that the user was trying to do actually the full model is being illustrated in the predictive control book . i mean have you tried to run the model and it worked ? am using matlab version 2016a so idon't know if there's a comptability problem.
so my question is does the first part of the code has to be implment in the call backs and i have to change all the given variables to somthing_value e.g. sf_nom has to be sf_nom_value to work with the code ??
and when i add the additional paramters to the model it has to get a signal from somewhere which i don't know ?
i have alos attached my model so you can see we are working almost on the same thing. . i even have tried the data store memory thing which you mentioned in your explantion then i find our that Simulink.Signal Object is better for multiple global data but still recieve no result .
Walter Roberson
2022년 5월 24일
I got the parameters and global variables working when I was helping the person. The overall code could not be run because of the unexpected 2x1 vector that I discussed in that Answer. (There is a bus that is being split into two entities instead of into three, so one ends up as a vector.)
amr makhlouf
2022년 5월 24일
alright so my question is i have to make a simulink signal to all global variables that includes : Ts Rs Lr Lm Ls p tr kr r_sigma t_sigma lambda v states ?? in the model explorer >> model workspace.
then i have to intialize the model variables till sim () in the call backs then rest of the codes in the matlab function , please correct me if am wrong ?
Walter Roberson
2022년 5월 26일
I have attached the editted models I created in that linked Question.
When you run this, you will quickly get an error. It will say
Error using run_MPC (line 67)
Errors occurred during parsing of MATLAB function 'MPC_DTC_IM/MATLAB Function'
This is because
Incorrect dimensions for matrix multiplication.
Check that the number of columns in the first matrix matches the number of rows in the second matrix.
To perform elementwise multiplication, use '.*'.
Function 'MATLAB Function' (#64.1097.1116), line 38, column 18: "(kr/tr-kr*1i*wm)*Fr"
The reason for this is what I explained in the previous question, about the bus with 3 elements being split into two locations, leading to a vector in an unexpected place. Which is outside of the domain of the question about how to set parameters and global variables.
amr makhlouf
2022년 5월 27일
unfourtantely i have matlab 2016a , i cannot run it . i understand the matrix problem but my question is do i have to put the first part of the code in the intial function in call backs or just put all of the code in the m file , excuse me am way to new to matlab and am trying to learn
Walter Roberson
2022년 5월 27일
This is specifically about using matlab to set up parameters and globals, and then use sim() to run the model. This code is not designed to be put into initfcn. It is potentially possible that some of it could be moved to initfcn callbacks, but it was not designed around that possibility.
amr makhlouf
2022년 5월 28일
i have attached the final matlab file i have made following all the steps in this thread :
1- define a signal and data store memory for global variables.
2- defining all the code inside the m file and the intial function in call backs
3- checked that every blocks work just fine sattrting from the induction motor model to lc filter that i have made
4- i even get an outside space vector modulation controller to make sure that my model is working . however i still recieve errors regarding data type could you plese let me know how can i fix this . thank you so much
akram amri
2024년 2월 8일
Hello, I have the same problem Did you solve the code? Could you please give me the corrected code?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)