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);
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!