Utilising matlab plots to find constants
1 回表示 (過去 30 日間)
古いコメントを表示
Finding m and c for an equation y = mx + c, with the help of math and plots.
In this case, y is data_model_1, x is time
Avoid other matlab functions like fitlm as it defeats the purpose.
I am having trouble finding the constants m and c. I am trying to find both m and c by limiting them to a range (Based on smart guess) and I need to deduce the m and c values based on the mean error range. The point where mean error range is closest to 0 should be my m and c values.
load(file)
figure
plot(time,data_model_1,'bo')
hold on
for a = 0.11:0.01:0.13
c = -13:0.1:-10
data_a = a * time + c ;
plot(time,data_a,'r');
end
figure
hold on
for a = 0.11:0.01:0.13
c = -13:0.1:-10
data_a = a * time + c ;
mean_range = mean(abs(data_a - data_model_1));
plot(a,mean_range,'b.')
end
EDIT: I have attached an example with the file "fil"
3 件のコメント
Jan
2018 年 10 月 8 日
While there is no polyfit in your code, it is easy to determine the constants m and c using maths instead of plots.
Again: What is the problem with the code you have posted?
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!