- #1
- 2,168
- 193
I have a lineer data and I want to write the equation of it on the graph.
The x-axis is inverse distance (1/m) and I showed as "d"
The y-axis is capacitance (C) and I showed it like "C"
My data name is d_C
Here my codes that I used for now
>> d=d_C(:,1);
>> C=d_C(:,2);
>> plot(d,C,'go');
>> hold on
>> xlabel('Inverse Distance (1/m)','Fontsize',21)
>> ylabel('Capacitance (C)','Fontsize',21)
>> title('Inverse Distance vs Capacitance,Part (A)','Fontsize',23)
>> grid on
>> p = polyfit(d,C,1)
p =
0.0003 0.0414
>> Cfit=polyval(p,d);
>> plot(d,Cfit,'-b');
>> h = legend('Data','Best fit','Location','southeast');
>> set(h,'Fontsize',20);
I just need to write the equation on the graph like probably y=0.0003x+0.0414 (I am not sure about this though).I need codes.I can't do it on manually
Any help would be great
Thanks
The x-axis is inverse distance (1/m) and I showed as "d"
The y-axis is capacitance (C) and I showed it like "C"
My data name is d_C
Here my codes that I used for now
>> d=d_C(:,1);
>> C=d_C(:,2);
>> plot(d,C,'go');
>> hold on
>> xlabel('Inverse Distance (1/m)','Fontsize',21)
>> ylabel('Capacitance (C)','Fontsize',21)
>> title('Inverse Distance vs Capacitance,Part (A)','Fontsize',23)
>> grid on
>> p = polyfit(d,C,1)
p =
0.0003 0.0414
>> Cfit=polyval(p,d);
>> plot(d,Cfit,'-b');
>> h = legend('Data','Best fit','Location','southeast');
>> set(h,'Fontsize',20);
I just need to write the equation on the graph like probably y=0.0003x+0.0414 (I am not sure about this though).I need codes.I can't do it on manually
Any help would be great
Thanks
Attachments
Last edited: