Extracting value from array

31 Ansichten (letzte 30 Tage)
Charlotte van Baal
Charlotte van Baal am 24 Okt. 2023
Bearbeitet: Stephen23 am 24 Okt. 2023
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.

Akzeptierte Antwort

Stephen23
Stephen23 am 24 Okt. 2023
Bearbeitet: Stephen23 am 24 Okt. 2023
"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);

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by