Code to Extract Value from A Specific Cell during Simulation
1 view (last 30 days)
Show older comments
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.
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 Comment
KALYAN ACHARJYA
on 17 Jul 2019
Edited: KALYAN ACHARJYA
on 17 Jul 2019
No Screenshot please. Do attach the code using clip button or paste the code using Alt+Enter
Answers (1)
Samatha Aleti
on 31 Jul 2019
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
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!