フィルターのクリア

I get this error when using randn "Size inputs must be scalar."

1 回表示 (過去 30 日間)
lucky_
lucky_ 2016 年 1 月 22 日
コメント済み: Walter Roberson 2016 年 1 月 22 日
I'm trying to plot the data point and x data coordinate but I'm getting
this error "Size inputs must be scalar."
trainSample = 2000;
testSample = 200000;
[trainData, trainTarget] = myfunction(trainSample);
[testData, tesTarget] = myfunction(testSample);
x=[trainingData, trainingTarget];
y= [testingData, testingTarget];
dataset = randn(trainSamples,2);
dataset2 = randn(trainData,2);
%dataset2 = randn(x,1);
figure
hold on
plot(dataset(:,1) , dataset(:,2) , 'r.');
hold off
hold on
plot(dataset2(:,1) , dataset2(:,2) , 'b.');
hold off
xlabel('x-value');
ylabel('y-value');
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 1 月 22 日
Please show the complete error message, everything in red.
lucky_
lucky_ 2016 年 1 月 22 日
@Walter Roberson
Error using randn Size inputs must be scalar.
Error in draft (line 32) dataset2 = randn(trainData,2);

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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 22 日
編集済み: Walter Roberson 2016 年 1 月 22 日
My guess is that you want to replace
dataset2 = randn(trainData,2);
with
dataset2 = randn(testSample,2);
Also notice that trainSamples and trainSample are not the same variable.
  5 件のコメント
Torsten
Torsten 2016 年 1 月 22 日
A variable named "trainSamples" does not exist in your code (only "trainSample").
Best wishes
Torsten.
Walter Roberson
Walter Roberson 2016 年 1 月 22 日
dataset = trainData(:,1:2);
dateset2 = testData(:,1:2);
plot(dataset(:,1) , dataset(:,2) , 'r.');
hold on
plot(dataset2(:,1) , dataset2(:,2) , 'b.');

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

Community Treasure Hunt

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

Start Hunting!

Translated by