How to change r code to Matlab

3 ビュー (過去 30 日間)
Emilee Burris
Emilee Burris 2019 年 4 月 5 日
編集済み: Bjorn Gustavsson 2019 年 4 月 5 日
I have a code for linear fit in r that I want to do in matlab. I have converted up to this point and then not exactly sure how to do the rest.
This is a simple linear regression in r that uses the lm function that is "linearmodel" to create a simple linear regression model
fit=lm(dependant variable ~ indepentand varible)
the reture should be the coefficients of the model
Is there a way to do this in matlab
fit <- lm((log(obs$O2)-log(0.247))~ obs$depth + 0)
  2 件のコメント
dpb
dpb 2019 年 4 月 5 日
My R syntax is too rusty...what's the wanted model in something can decipher?
Walter Roberson
Walter Roberson 2019 年 4 月 5 日
depth to be fit to O2^0.247 ??

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

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 4 月 5 日
編集済み: Bjorn Gustavsson 2019 年 4 月 5 日
Well if it is as simple as a fit of a line to data you can always use polyfit, or lscov if you have known uncertainties in your measurements. Those functions is what I typically start with for fitting low-order polynomials to data. Those would give you polynomial coefficients (polyfit) and whatever coefficients you'd fit for with the lscov function (it allows you to build your fitting matrix A with whatever you like not just values of powers of independent variable...)
HTH

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by