Why does my data have more than 2 dimensions?

I used the "Data Logging" tool in Simulink to collect the outputs of a model, but there seems to be a dimensions problem with one of them.
I extracted the values of the different signals using
>>test=logsout.getElement(1).Values.Data;
but when trying to plot it, I get "Error using plot. Data cannot have more than 2 dimensions." While other signals have the format 18001x1 double, this one has the format 1x1x18001 double. When typing the signal name in the command window, the values look like this:
>>test
test(:,:,204) =
4.2991
test(:,:,205) =
4.2156
test(:,:,206) =
4.2530
How can I convert the Signal to a "normal" one (just the values)?

 채택된 답변

ES
ES 2017년 3월 24일

1 개 추천

test = test(:,:)'
will convert your 1x1x18001 to 18001x1

추가 답변 (1개)

dbmn
dbmn 2017년 3월 24일

1 개 추천

There is multiple options to force your 3d data into a vector
Option 1: use dot notation
% gets you a column vector
a(:) = test(1,1,:);
% gets you a row vector
b(:,1) = test(1,1,:);
Option 2: Shape to your likings
c = reshape(test, [numel(test), 1]);

댓글 수: 2

C Kroeger
C Kroeger 2017년 3월 24일
The first Option didn't work: "Conversion to cell from double is not possible."
The second however did work. The solution of "chocolate Warrior" seems simpler though.
Option 2 worked. thank you

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Naming Conventions에 대해 자세히 알아보기

제품

질문:

2017년 3월 24일

댓글:

2022년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by