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);

답변 (1개)

Walter Roberson
Walter Roberson 2017년 7월 16일
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.

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

2017년 7월 15일

답변:

2017년 7월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by