필터 지우기
필터 지우기

Extracting value from array

조회 수: 8 (최근 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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by