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

2 次查看(过去 30 天)
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);

采纳的回答

Steven Lord
Steven Lord 2017-12-18
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by