gurehbgui
gurehbgui

Reputation: 14684

how to get a 1x4 double from 1x1x4 double?

I have a value with the type 1x1x4 double and need to make a 1x4 double out of it.

The problem is, I dont know how to do it. Can anybody help me?

It looks like:

val(:,:,1) =

    0.5601


val(:,:,2) =

    0.4876


val(:,:,3) =

    0.8146


val(:,:,4) =

    0.6207

But it should be:

1x4 double = 
    0.5601    0.4876    0.8146     0.6207

Upvotes: 0

Views: 218

Answers (2)

Gunther Struyf
Gunther Struyf

Reputation: 11168

If all the other dimensions are singleton, and the result would be just a 1D vector, you can also use the following:

val(:)'

Upvotes: 2

Dan
Dan

Reputation: 45752

You can get rid of singleton dimensions using the squeeze function: squeeze(val)'

You can also look at reshape or permute if your problem is a bit more complex

Upvotes: 4

Related Questions