How to input values from workspace to PV array Block?
조회 수: 8 (최근 30일)
이전 댓글 표시
I have currently created a simple model containing the PV array block from library location - Simscape / Electrical / Specialized Power Systems / Renewables / Solar, I am trying to input the specifications of the module data for the 'Voc' using a variable (ie. Volt_oc) from the Workspace. But when i do so i am getting this error:![error.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/236769/error.jpeg)
![error.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/236769/error.jpeg)
or if i use the 'set_param' command in script i am getting this error also:
![error2.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/236770/error2.jpeg)
It works perfectly fine if i was to input a number into the PV array block, but as i have a loop containing multiple values to simulate, i would like to use a variable from the workspace to minise human interaction.
댓글 수: 2
Fangjun Jiang
2019년 9월 3일
What number did you put in that makes it work fine?
What variable and what its value did you try to put in?
답변 (1개)
Naveen Venkata Krishnan
2019년 10월 7일
Hello Jack ,
From the question I understood that you are changing the "Module" in the "Module data" of the PV array to unser defined thereby you can define a new PV module and assuming that you might be using MATLAB 2019a
Module data -> Module -> user defined.
The PV array module that you are using is a masked block, it has it's own workspace hence directly giving varible values from Base work space.
In order to read the data from the base workspace follow these steps :
1 . In the field where the value has to be accessed from workspace ( here open circuit voltage )
![step-1.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/241478/image.png)
2 . Then click on "Voc: Create..." which will lead you to this
![step-2.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/241479/image.png)
Enter the value( < expression > , here I have given it an intial value of 40 ) you want to assign to the variable in workspace "Voc" and then press create
3 . This will create a variable Voc in work space as shown
![step-3.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/241480/image.png)
This variable can now be called from SIMULINK as any other MATLAB variable
댓글 수: 1
adham osama
2021년 2월 6일
The problem is the need to use variables directly from matlab base workspace which has been initialized in an m-file, for example.
Example: these variables are defined in an m-file
I_sc = 4.37; % [A]
V_oc = 42.93; % [V]
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/510982/image.png)
using a variable name for Ncell generates another error : Matrix dimensions must agree
Btw, same error occurs when using your method and tring to click "apply".
참고 항목
카테고리
Help Center 및 File Exchange에서 Switches and Breakers에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!