![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1520011/image.png)
Extracting value from array
조회 수: 11 (최근 30일)
이전 댓글 표시
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1519981/image.jpeg)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1519986/image.jpeg)
All values:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1519991/image.jpeg)
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.
댓글 수: 0
채택된 답변
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1520011/image.png)
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!