我的Matlab情节有问题。我必须在我收集的数据点上使用sin函数。我成功了,但当我尝试通过set
函数输入一些参数(即LineWidth)时,它总是在set
的行显示错误,我不知道为什么。
这是我的代码可行,但当我“激活”设置行时,它会显示错误:
clear all;
close all;
C0 = [0]; C1 = [0]; C2 = [0]; C3=[0];
run('traces3');
traces3;
t = datetime ('now');
gri = 0;
filename = 'image.png';
M = [(P(2,1)-P(1,1)), (P(4,1)-P(1,1)), P(1,1);
(P(2,2)-P(1,2)), (P(4,2)-P(1,2)), P(1,2);
0,0,1;];
M2 = inv(M);
clear tmp1;
clear tmp2;
tmp1 = size (C0);
tmp2 = ones(tmp1(1),1);
C_0 = (M2*([C0, tmp2])')';
c0 = sortrows(C_0);
clear tmp1;
clear tmp2;
f0 = fit(c0(:,1),c0(:,2),'sin1');
figure(1)
A0 = size(c0);
a0 = c0(A0(1),1);
h0 = plot(f0, 'b-');xlim([0,a0])
hold on
h_0 = plot(c0(:,1),c0(:,2),'bo');xlim([0,a0])
coul=1;
tit=['File: "',filename,'" ',datestr(t)];
title(tit,'FontSize',20,'Color','k')
f0a=num2str(round(f0.a1,2)); f0b=num2str(round(f0.b1,2)); f0c=num2str(round(f0.c1,2));
legend('C0 raw',['F0(x)=', f0a ,'*sin(', f0b ,'x+', f0c ,')'],'Location','southwest')
if(gri~=0)
grid on
end
%set(h0,'LineWidth', 2) %When I write this line in the code it doesn't work anymore...
hold off
print(tit,'-dpdf')
答案 0 :(得分:0)
情节句柄h0=plot(...)
是 行 对象的句柄数组,而不是图形对象!!!。
只需在绘图处理向量length(h0)
处尝试每个h0
行对象:
iline=1;
set(h0(iline),'LineWidth', 2); % This line should work now...