1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 温度补偿计算公式_温度补偿 matlab 计算

温度补偿计算公式_温度补偿 matlab 计算

时间:2024-06-14 00:41:51

相关推荐

温度补偿计算公式_温度补偿 matlab 计算

计算908的温度拟合曲线

%%

close all;

clc;

clear;

%%

str = 'E:\matlab\kc908_temp_data\';%获取路径

files = dir(strcat(str,'*.txt'));%扫描当前文件夹下的txt文件

number_files = length(files);%获取文件数量

%%

list_freq = zeros(number_files);

for i=1:number_files

freq(i) = str2num(files(i).name(regexp(files(i).name,'\d')));%获取字符串中的数字,并转换为数字

end

[B,index]=sort(freq);

%%

N = 6;

a = zeros(number_files,N+1);

fun_name = blanks(number_files);%申请一个字符串数组

%%

for i=1:number_files

str1 = sprintf('%s%s',str,files(index(i)).name);

[temp,lev] = textread(str1,'%f,%f');%读取指定文件

L = length(temp);

x = temp;

if(x(1) - x(end) > 0)

diff = lev(end);

else

diff = lev(1);

end

y = lev - diff;

% y(i,:) = lev;

a(i,:) = polyfit(x,y,N)%获取多项式

figure;

plot(x,y);%画图

freq = str2num(files(index(i)).name(regexp(files(index(i)).name,'\d')));%获取字符串中的数字,并转换为数字

if (freq < 1e3)

str2 = sprintf('%s%.1f%s','频率:',freq,'Hz');

elseif(freq <1e6)

str2 = sprintf('%s%.4f%s','频率:',freq/1e3,'kHz');

elseif(freq < 1e9)

str2 = sprintf('%s%.7f%s','频率:',freq/1e6,'MHz');

else

str2 = sprintf('%s%.10f%s','频率:',freq/1e9,'GHz');

end

title(str2);

legend('温度-幅度');%曲线内容

xlabel('温度');

ylabel('幅度');

end

%%

% zz = (1:number_files);

% xx = x(zz,:);

% yy = y(zz,:);

% figure;

% plot3(xx,yy,zz,'.b');

% grid on;

% figure;

% mesh(zz,xx,yy);

%%

%阶数判断

% for i=1:5

% y2=polyfit(x,y,i);

% Y=polyval(y2,x);%计算拟合函数在x处的值。

% if sum((Y-y).^2)<0.1

% c=i

% break;

% end

% end

% clear;

% clc;

close all;

% a = [

% -0.0000 0.0000 -0.0000 0.0002 -0.0383 -0.0294

% 0.0000 -0.0000 0.0000 -0.0000 -0.0355 0.0785

% 0.0000 -0.0000 0.0000 0.0001 -0.0389 0.0752

% 0.0000 -0.0000 0.0000 -0.0004 -0.0280 0.2828

% 0.0000 -0.0000 0.0000 -0.0005 0.0160 -0.0965

% -0.0000 0.0000 0.0000 -0.0005 -0.0152 0.1324

% -0.0000 0.0000 0.0000 -0.0030 0.0125 -0.0170];

tempr = 0:1:70;

N = 7;

bb = zeros(N,length(tempr));

for i = 1:N

c = a(i,N-6) .* tempr.^6 +a(i,N-5) .* tempr.^5 + a(i,N-4) .* tempr.^4 + a(i,N-3) .* tempr.^3 ...

+ a(i,N-2) .* tempr.^2 + a(i,N-1) .* tempr.^1 + a(i,N) .* tempr.^0;

figure;

plot(tempr,c);

end

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。