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 个评论
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!