Code to Extract Value from A Specific Cell during Simulation

1 次查看(过去 30 天)
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 个)

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 中查找有关 Simulink 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by