Transform a struct to a matrix to feed it into SVD() function
2 views (last 30 days)
Show older comments
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);
0 Comments
Accepted Answer
Steven Lord
on 18 Dec 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!