indepvar and depvar are of inconsistent sizes with polyfitn
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mohamed gryaa
le 4 Sep 2019
Commenté : mohamed gryaa
le 4 Sep 2019
when i use polyfitn with matlab say indepvar and depvar are of inconsistent sizes and i don't now where i am wrong can yo help me?
this is the data:
x1=[2.2 2.2 2.2 2.44 2.49 2.48 2.45 2.2 2.39 2.38];
>> x2=[29.4 30.9 32.9 26.9 28 28.8 30.1 29.4 28.8 30];
>> y=[7.5 7.02 6.94 7.91 7.96 7.91 7.78 7.42 7.86 7.47];
p=polyfitn([x1,x2],y,1)
Error using polyfitn (line 172)
indepvar and depvar are of inconsistent sizes.
0 commentaires
Réponse acceptée
Bjorn Gustavsson
le 4 Sep 2019
Yes, you send in an array [x1,x2] of size [1 x 20] and an array y of size [ 1 x 10] into polyfitn. The polyfitn version I have (a matlab-central submission by John d'Errico from 2006) gives me a more sensible result after transposing your inputs:
p=polyfitn([x1;x2]',y',1)
p =
ModelTerms: [3x2 double]
Coefficients: [1.5589 -0.11979 7.4607]
ParameterVar: [0.1693 0.0010284 2.9687]
ParameterStd: [0.41146 0.032068 1.723]
R2: 0.91523
RMSE: 0.10284
VarNames: {}
This was my curse when starting to use matlab - I solved it by the very sofisticated technique:
If it doesn't work transpose, transpose again until all combinations have been tried.
You might do the same but a more intelligent aproach is to check the documentation and input variables.
HTH
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Time Series Events dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!