MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Ida 1
0

What does ''Error using horzcat Dimensions of arrays being concatenated are not consistent'' means in the problem below?

Ida 1
さんによって質問されました 2019 年 3 月 30 日
最新アクティビティ Ida 1
さんによって 編集されました 2019 年 4 月 23 日 22:03
y=1:4738;
lag1=y(6:end-1);
lag2=y(5:end-2);
M = [lag1, lag2,ones(size(y))];
b = M\y

  1 件のコメント

You forgot to attach your data, or even any screenshots.
And what is a "speak"? In English, speak means to talk.

サインイン to comment.

1 件の回答

回答者: John D'Errico
2019 年 4 月 1 日
編集済み: John D'Errico
2019 年 4 月 1 日
 採用された回答

The problem is, we do not see your data. Only you can. However the one thing that is painfully obvious is that your model is linear in the parameters. So the starting values are irrelevant.
This means that nothing in the universe will make your model fit the data better, because it is essentially the wrong model. (A linear model, which this is, has a unique optimal solution, regardless if you use a nonlinear solver or a linear one.)
How might we help you better? The only way to do this is to have your data. At the very least, it would be necessary to see it. Then we could know if some variation of the model you have chosen might fit better, or if that is not possible at all. So, if you want better help, you need to help us to help you.

  4 件のコメント

Sorry. I'll look at it later in the day. Gotta run now though.
I looked at your data. Your model is missing an important point, thatis, it has no constant term in it. Think of it as a DC bias. Using the data in the data1 array, for example, I can build the model as simply as:
M = [f1(pi/91,x(:,1)), f2(pi/91,x(:,1)), f2(pi/182,x(:,1)), x(:,2)];
b = M\Y
b =
78.886
23.973
24.334
38.694
There is no need to use fitnlm at all. Now, lets see what we just did.
plot(Y,'b.')
hold on
plot(M*b,'ro')
untitled.jpg
Essentially, your model has an oscillatory terms in it, but nothing that can account for a constant offset.
So, now add a constant term to the model.
M = [f1(pi/91,x(:,1)), f2(pi/91,x(:,1)), f2(pi/182,x(:,1)), x(:,2),ones(size(Y))];
b = M\Y
b =
75.29
11.665
11.694
36.762
1810.5
Now, redo the plot. Here, I've just plotted the first 400 points in the data set.
untitled.jpg
As you can see, it has the essential nature of your data, but your data is far more noisy than your model will ever account for. You can't expect much better than that. Just wanting a great fit is not sufficient. Good (i.e., low noise) data is important too.
Thank you, but in this case you are not doing a nonlinear fit. What about your R-squared here? So, I am not sure if I was clear enough, the problem in my model is to improve the descriptive statistics by using the same structure as above. The attached figure shows the model and the data.

サインイン to comment.



Translated by