内容纲要

pkg包

将下载的包放在左侧目录下后,或者打开包所在的目录

加载

pkg load symbolic-3.0.1.tar.gz
或者pkg load -forge symbolic-3.0.1.tar.gz

安装

pkg install symbolic-3.0.1.tar.gz

绘图

clear;
diameter=0.142;#unit mm
A=pi*[diameter/2]^2;#Calculate cross section
L=0.608;#original length
Force=[0,7330,15100,23100,30400,34400,38400,41300,44800,46200,47300,47500,46100,44800,42600,36400];
Length=[60.8,60.851,60.902,60.952,61.003,61.054,61.308,61.816,62.832,63.848,64.864,65.88,66.896,67.658,68.42,69.182];
stress=Force/A;
strain=(Length/100-L)/L;

这里后来改了一下,变成保形插值后再绘图,能丝滑一点

strainfit=0:strain(16)/99:strain(16);
stressfit = interp1 (strain, stress, strainfit, "pchip");
plot(strainfit,stressfit/10^6)
title ("strain-stress curve");
xlabel ("strain");
ylabel ("stress(MPa)");

线性函数过原点拟合(部分矩阵)

o=@(Emodulus,e)Emodulus*e;

Emodulus=lsqcurvefit(o,0,strain(1:5), stress(1:5));

fprintf(‘Elastic modulus=%d MPa\n’,Emodulus/10^6)

简单的线性拟合。。懒得整复杂了

or=@(Emodulus,er)Emodulus*(er-0.002);

P=polyfit(strain(6:16),stress(6:16),3);
oy=@(P,ey)(P(1)ey^3+P(2)ey^2+P(3)*ey+P(4));

P(3)=P(3)-Emodulus;
P(4)=P(4)+0.002Emodulus;
s=roots(P);
fprintf(‘yeild stress=%d MPa\n’,Emodulus
(double(s(3))-0.002)/10^6)
hold on;
er=0:double(s(3))/20:double(s(3));
or=Emodulus*(er-0.002);
plot (er,or/10^6,’r-‘);

后来发现,每次打开都要重新加载一次pkg,就很麻烦,但目前只是一门课要用OCTAVE写作业,就懒得解决这个小问题。。

标签:,

Leave a Reply

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据