Code to Extract Value from A Specific Cell during Simulation

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 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeDiscrete Multiresolution Analysis についてさらに検索

タグ

質問済み:

2019 年 7 月 17 日

回答済み:

2019 年 7 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by