Extracting value from array

31 ビュー (過去 30 日間)
Charlotte van Baal
Charlotte van Baal 2023 年 10 月 24 日
編集済み: Stephen23 2023 年 10 月 24 日
I want to use output from an encoder sensor to verify a system, but i don't get a struct with the right values i can use.
The values i get in my workspace are as follows:
I only need the part after the = sign.
I tried using signals.values(:,:,:) but i still get the val(...) and not only the value behind the = sign.
For one value it does work, but not for all of them.
One value:
All values:
Can someone tell me how i can extract the needed value after the = sign without the part in front of it. I want to put it in a struct.

採用された回答

Stephen23
Stephen23 2023 年 10 月 24 日
編集済み: Stephen23 2023 年 10 月 24 日
"For one value it does work, but not for all of them."
It does work, your screenshot clearly informs us that you are getting one single 1x1x5001 array:
That is exactly what MATLAB is showing you in the command window: all 5001 pages of that single array (each page happens to be scalar, but that does not really change how it is displayed):
"Can someone tell me how i can extract the needed value after the = sign without the part in front of it."
The part in front of the = sign does not exist, it is merely an artifact of how one single 3D array is displayed in the command window (it merely shows the variable name with the page index). Perhaps you are confusing the way the multiple pages of one array are displayed in the command window with having lots of separate arrays: once again: you only have one array, with shape 1x1x5001.
Because it is one array there is absolutely nothing stopping you from assigning it to one variable, e.g.:
X = phimot1.signals.values(1,1,:);
You can always RESHAPE that one array if you want, e.g. into a column vector:
X = reshape(phimot1.signals.values(1,1,:),[],1);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by