Matlab index in range yet I get out of range

1 回表示 (過去 30 日間)
Ahmad
Ahmad 2016 年 11 月 11 日
編集済み: Ahmad 2016 年 11 月 11 日
I'm trying to extract the model parameters using:
clc
clear all
data = xlsread('cancer_train.xlsx');
X = data(:,1:9);
Y = data(:,10);
mdl = fitcnb(X,Y);
mu=[];
[m,n] = size(data);
for i = 1:m
mu(i,1) = mdl.DistributionParameters{1,i}(1);
end
I get index out of range after element 9! The excel can be found here: http://dropcanvas.com/#S47z19vg5WISRQ

回答 (1 件)

KSSV
KSSV 2016 年 11 月 11 日
According to the code, what you pick, the loop should run till 9 only.
clc; clear all ;
clc
clear all
data = xlsread('cancer_train.xlsx');
X = data(:,1:9);
Y = data(:,10);
mdl = fitcnb(X,Y);
% [m,n] = size(data);
m = size(mdl.DistributionParameters,2) ;
mu = zeros(m,1) ;
for i = 1:m
mu(i,1) = mdl.DistributionParameters{1,i}(1);
end
  1 件のコメント
Ahmad
Ahmad 2016 年 11 月 11 日
編集済み: Ahmad 2016 年 11 月 11 日
That's not what I want, I want to get the mean of all features whose class is 1. I guess the first 9 ones are 1, that's why it stops? Any suggestions to work around this problem? perhaps an "if" to check if the class is 1, but what is the m?
Edit upon looking at the data, the first 9 ones are mixed, why the heck is it stopping after just 9?!
Edit: ohhh the i is the feature number?!!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by