Code to Extract Value from A Specific Cell during Simulation

조회 수: 3 (최근 30일)
Bryan
Bryan 2019년 7월 17일
답변: Samatha Aleti 2019년 7월 31일
Hi guys,
I have issues extracting my power output value during simulation. I have this code and the table of Pold from workspace. How do I extract only one value from one of the cells in workspace to be included in my array which I declared as [0;0;0;0]. If I have this many value so I dont know how to assign a value into my array which I need to use for the later part of my code.
Capture.PNG
if T<=0.05
D = DPold(1);
if T>0.045
Pold(1) = P;
end
elseif T>0.05 && T<=0.1
D = DPold(2);
if T>0.095
Pold(2) = P;
end
elseif T>0.1 && T<=0.15
D = DPold(3);
if T>0.145
Pold(3) = P;
end
elseif T>0.15 && T<=0.2
D = DPold(4);
if T>0.195
Pold(4) = P;
end
  댓글 수: 1
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 17일
편집: KALYAN ACHARJYA 2019년 7월 17일
No Screenshot please. Do attach the code using clip button or paste the code using Alt+Enter

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

답변 (1개)

Samatha Aleti
Samatha Aleti 2019년 7월 31일
Assuming you are able to access the cell from workspace during the simulation, one of the ways to access the cell element from a cell “C” at “i”th index is using C{i}.
Let the Original Array be “X”. I am assuming that the all the elements in “C” are of same data type. You can now include the cell element in the original array using the small code below:
Store = C{i};
for i =1:numel(Store)
X(end+1) = Store(i);
end

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by