Message Boards Message Boards

GROUPS:

[✓] Access elements of a QuantityArray?

Posted 1 month ago
204 Views
|
2 Replies
|
1 Total Likes
|

Hi, How do I access the individual elements of a QuantityArray? For example, if I initialize an array:

temps=QuantityArray[ConstantArray[0,5],"Kelvins"]

and then I'd like to change the third element of temps to 273 K.

Thanks, Tony

2 Replies

I guess you are asking for ReplacePart, e.g. try:

temps = QuantityArray[ConstantArray[0, 5], "Kelvins"];
temps = ReplacePart[temps, 3 -> Quantity[273, "Kelvins"]];
temps[[3]]
Posted 1 month ago

Thanks Henrik! That's perfect.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract