horzcat error Conversion to struct from double is not possible.

3 次查看(过去 30 天)
??? 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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by