Utilising matlab plots to find constants

3 次查看(过去 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 个评论
Madlab
Madlab 2018-10-8
编辑:Madlab 2018-10-8
How to find the constants m and c with the help of plots?
I know there are other methods but I need to use mathematics and plots to solve for m and c, nothing else. There is no polyfit function anywhere in my code either.
Jan
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 CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by