horzcat error Conversion to struct from double is not possible.

3 ビュー (過去 30 日間)
rachna malik
rachna malik 2017 年 7 月 15 日
回答済み: Walter Roberson 2017 年 7 月 16 日
??? 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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by