Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab: how do I change the way a matrix is stored? from 1x1x3 to 1x3?

Tags:

matlab

I currently have:

val(:,:,1) =

    0.7216

val(:,:,2) =

    0.7216

val(:,:,3) =

    0.7216

But I want

0.7216, 0.716, 0.721.

What sort of operation can I do to do that?

like image 468
NullVoxPopuli Avatar asked Jan 20 '23 17:01

NullVoxPopuli


1 Answers

The reshape function will do the trick here:

% Arrange the elements of val into a 1x3 array
val = reshape(val, [1 3]);

Because you are converting to a row-vector, the following syntax will also work:

val = val(:)';

Because val(:) creates a column-vector, and the transpose operator ' then transposes that column-vector into a row-vector.

like image 141
Wesley Hill Avatar answered Mar 19 '23 13:03

Wesley Hill