PSCAD, Matlab interfacing

I have simulation program called PSCAD which contains PID controller. I put Kp as a variable that get its value from matlab file(.m). The matlab file contains if and for loops (bacterial foraging algorithm) to determine the value of Kp. The time step for pscad execution the simulation is 0.001 sec, i.e (every 0.001 sec the program call the matlab file to get Kp) to run the simulation. All i want to know that how to make matlab file time step is 0.001 sec to be equal to pscad time step.

2 Comments

Dear Mohamed,
I am doing the same research with the PSCAD and MATLAB interface. The problem is that the PSCAD can not detect any version of the installed MATLAB. I would appreciate if you could help me at:
moh.arzani@gmail.com
Thanks a lot. :))
Mehrab
Mehrab on 6 May 2026 at 11:25
I also doing the same research. I instal Intel Fortran and PSCAD know my MATLAB, but the simulation gives this errores:
TypeIdComponentNamespaceDescriptionGFMIPrimeryLoop14050202Edit3libcpmt.lib(newaop.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1800' doesn't match value '1900' in main.objGFMIPrimeryLoop14050202Edit3emtdc.lib(ClientExchange.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)GFMIPrimeryLoop14050202Edit3emtdc.lib(CoSimulationExchange.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)GFMIPrimeryLoop14050202Edit3main.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z) referenced in function "int __cdecl EmtdcV4(int,char * * const)" (?EmtdcV4@@YAHHQEAPEAD@Z)GFMIPrimeryLoop14050202Edit3emtdc.lib(exchange.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)GFMIPrimeryLoop14050202Edit3emtdc.lib(OutputFile.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)GFMIPrimeryLoop14050202Edit3emtdc.lib(Collections.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)GFMIPrimeryLoop14050202Edit3emtdc.lib(outxmsg.obj) : error LNK2001: unresolved external symbol __acrt_iob_funcGFMIPrimeryLoop14050202Edit3Solver.lib(amd_global.obj) : error LNK2001: unresolved external symbol __acrt_iob_funcGFMIPrimeryLoop14050202Edit3Solver.lib(colamd_global.obj) : error LNK2001: unresolved external symbol __acrt_iob_funcGFMIPrimeryLoop14050202Edit3main.obj : error LNK2019: unresolved external symbol __acrt_iob_func referenced in function "int __cdecl EmtdcV4(int,char * * const)" (?EmtdcV4@@YAHHQEAPEAD@Z)GFMIPrimeryLoop14050202Edit3emtdc.lib(exchange.obj) : error LNK2001: unresolved external symbol __acrt_iob_funcGFMIPrimeryLoop14050202Edit3emtdc.lib(datetime.obj) : error LNK2001: unresolved external symbol __acrt_iob_funcGFMIPrimeryLoop14050202Edit3emtdc.lib(cfortran.obj) : error LNK2001: unresolved external symbol __acrt_iob_funcGFMIPrimeryLoop14050202Edit3emtdc.lib(outxmsg.obj) : error LNK2001: unresolved external symbol __stdio_common_vfprintfGFMIPrimeryLoop14050202Edit3Solver.lib(amd_global.obj) : error LNK2001: unresolved external symbol __stdio_common_vfprintfGFMIPrimeryLoop14050202Edit3Solver.lib(colamd_global.obj) : error LNK2001: unresolved external symbol __stdio_common_vfprintfGFMIPrimeryLoop14050202Edit3main.obj : error LNK2019: unresolved external symbol __stdio_common_vfprintf referenced in function fprintfGFMIPrimeryLoop14050202Edit3emtdc.lib(exchange.obj) : error LNK2001: unresolved external symbol __stdio_common_vfprintfGFMIPrimeryLoop14050202Edit3emtdc.lib(datetime.obj) : error LNK2001: unresolved external symbol __stdio_common_vfprintfGFMIPrimeryLoop14050202Edit3emtdc.lib(cfortran.obj) : error LNK2001: unresolved external symbol __stdio_common_vfprintfGFMIPrimeryLoop14050202Edit3emtdc.lib(exchange.obj) : error LNK2019: unresolved external symbol __stdio_common_vfwprintf referenced in function wprintfGFMIPrimeryLoop14050202Edit3emtdc.lib(OutputFile.obj) : error LNK2019: unresolved external symbol __stdio_common_vsnprintf_s referenced in function "int __cdecl _snprintf_s<256>(char (&)[256],unsigned __int64,char const *,...)" (??$_snprintf_s@$0BAA@@@YAHAEAY0BAA@D_KPEBDZZ)GFMIPrimeryLoop14050202Edit3emtdc.lib(datetime.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf referenced in function sprintfGFMIPrimeryLoop14050202Edit3emtdc.lib(cfortran.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintfGFMIPrimeryLoop14050202Edit3emtdc.lib(datetime.obj) : error LNK2019: unresolved external symbol __stdio_common_vsscanf referenced in function sscanfGFMIPrimeryLoop14050202Edit3emtdc.lib(outxmsg.obj) : error LNK2001: unresolved external symbol __stdio_common_vsscanfGFMIPrimeryLoop14050202Edit3GFMIPrimeryLoop14050202.exe : fatal error LNK1120: 7 unresolved externalsGFMIPrimeryLoop14050202Edit3NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\link.exe"' : return code '0x460'GFMIPrimeryLoop14050202Edit3Unable to generate a simulation executable for namespace 'GFMIPrimeryLoop14050202'

Sign in to comment.

Answers (3)

Hi Mohamed,
To synchronize the timing of your MATLAB script with the PSCAD simulation, you need to ensure that your MATLAB code runs and updates the Kp value every 0.001 seconds.
  • Implement a timing mechanism in your MATLAB script to ensure that each iteration of updating Kp is completed within the specified time step.
  • Use tic and toc to measure execution time, ensuring that the function execution aligns with the 0.001-second interval.
Here is an example which demonstrates the updating of Kp value at every 0.001 sec
function Kp = getUpdatedKp()
persistent iteration;
persistent Kp;
if isempty(iteration)
iteration = 1;
Kp = 1; % Initial Kp value
end
tic; % Start timing
% Perform the bacterial foraging algorithm or other updates to Kp
Kp = Kp + 0.1 * randn; % Example update
% Enforce the 0.001-second time step
while toc < 0.001
% Busy-wait until 0.001 seconds have elapsed
end
iteration = iteration + 1;
end
For more information on usingtic and toc, you can refer to the following links
Ahmed
Ahmed on 18 Nov 2024
Hi Mohamed /Mohsen,
CAn you please follow the below link, hopefully it answers your query
I will quote from the PSCAD manual the following for your convenince
"To try and speed up the MATLAB solution, it is often a good idea to try and use a larger time step when invoking MATLAB components (wherever possible or practical). An enable/disable switch can also be implemented, so as to allow PSCAD to operate at close to full speed".

Asked:

on 23 Dec 2015

Commented:

on 6 May 2026 at 11:25

Community Treasure Hunt

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

Start Hunting!