Transform a struct to a matrix to feed it into SVD() function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
AHMED MAZARI
el 18 de Dic. de 2017
Respondida: Steven Lord
el 18 de Dic. de 2017
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 comentarios
Respuesta aceptada
Steven Lord
el 18 de Dic. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!