【发布时间】:2018-11-27 15:34:11
【问题描述】:
我有一组数据需要为(一阶polyfit)生成两条线性最佳拟合线,但我不知道如何指定每条线应适合数据的区域。我需要最小 x 值和 0 之间的区域中的一条线,以及 0.25
另外,在第二个区域中,有两个清晰的数据区域,一个在另一个之上,我需要将最佳拟合线仅拟合到较低的区域。
我是 Matlab 的新手,因此非常感谢任何帮助
%load data, force and velocity
load ('exp_6_Force');
load ('exp_6_Velocity');
% Give a name to the title bar.
set(gcf,'name','Experiment 6 velocity','numbertitle','off')
%set variables to x and y
x = Force;
y = Velocity;
%plot the graph
plot(x,y);
%add grid and legend
grid on;
legend ('Velocity');
%add labes and title
xlabel ('Force');
ylabel ('Velcoity');
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
%find coordinates of y min point
[value,index1] = min(y);
yminxcoor = x(index1);
yminycoor = y(index1);
【问题讨论】:
-
在此处查看逻辑索引 (de.mathworks.com/company/newsletters/articles/…)。
-
对于区域,您是指区域 1 的 x_min
-
@BanghuaZhao 第一个地区是,第二个地区没有。对于第二个区域,我只对紧密分组且 x>0.25 的数据感兴趣。这应该对图像有意义。
标签: matlab graph new-operator