horzcat error Conversion to struct from double is not possible.

??? Error using ==> horzcat
The following error occurred converting from double to struct:
Error using ==> struct
Conversion to struct from double is not possible. Error in ==> svds at 65 B = [sparse(m,m) A; A' sparse(n,n)];
Error in ==> srmsvd at 9 [u,s,v,flag] = svds(A,neigs,'L',opts);
Error in ==> run_srm at 4 srmsvd(datapath,neigs);
code where error is occuring
:
function [U,S,V,flag] = svds(varargin)
A = varargin{1};
[m,n] = size(A);
p = min(m,n);
q = max(m,n);
B = [sparse(m,m) A; A' sparse(n,n)];
srmsvd:
function [] = srmsvd(datapath,neigs)
A = load(datapath)
disp 'data loaded'
disp(['neigs set to ' num2str(neigs)])
opts.issym = 0;
opts.isreal = 1;
opts.disp = 0;
[u,s,v,flag] = svds(A,neigs,'L',opts);
run_srm:
datapath = 'twitter_data.mat'; %path to matlab file with sparse data matrix
neigs = 50; %number of eigenvectors
srmsvd(datapath,neigs);

Respuestas (1)

The result of
A = load(datapath)
is going to be a struct in which there is one field for every variable loaded from the .mat file. You need to extract the appropriate variable.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Jul. de 2017

Respondida:

el 16 de Jul. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by