Transform a struct to a matrix to feed it into SVD() function

1 Ansicht (letzte 30 Tage)
x=load('/local/mazari/np_vector.mat') Hello,
l have the following mat file created from python as follow :
import numpy as np
import scipy.io as sio
vect = np.random.randn(200,400)
sio.savemat('np_vector.mat', {'vect':vect})
l opened it in matlab as follow :
x=load('np_vector.mat')
x =
struct with fields:
vect: [200×400 double]
x =
struct with fields:
vect: [200×400 double]
but it's a struct, l cann't display the values, access certain rows and columns given the index
l would like to transform this struct into a matrix in order to get the SVD decomposition.
[Phi,Lambda,PhiT] = svd(x);

Akzeptierte Antwort

Steven Lord
Steven Lord am 18 Dez. 2017
The title of your post is a bit misleading. You don't want to transform the struct into a matrix, you want to extract the matrix from the struct. You do that using dot indexing.
theMatrix = x.vect;
Now work with the variable theMatrix.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by