我正在尝试编写一个脚本,以便求和执行这两个方程:
((−b*σ*yn)/(2))+∑(−σ*(1-((yi)/(yn)))*ab*nbi,i,1,Nf)
这:
((b*s*yn^(2))/(3))+∑(−σ*(1-((yi)/(yn)))(yi-yn)*ab*nbi,i,1,Nf)
我的代码是:
Prgm
Local b,h,n,nf,n_tot,mf,ub,lb,hi,ii,msg,y,yn,σ,ab,eq1,eq2
Disp ""
Request "b :",b
Request "h :",h
Request "Ab :",ab
Request "N : ",n
Request "Mf : ",mf
Request "N° tot : ",n_tot
Request "N° over N-A : ",nf
newMat(nf,2)→hi
For ii,1,nf,1
Request "h i-i:",msg
msg→hi[ii,1]
Request "b i-i:",msg
msg→hi[ii,2]
EndFor
Disp "matrix",hi
newMat(1,1)→eq1
newMat(1,1)→eq2
For ii,1,nf,1
((-b*σ*yn)/2) + (−σ*(1-((hi[ii,1])/(yn)))*ab*hi[ii,2])→eq1[ii,1]
((b*s*yn^2)/3) + (−σ*(1-((hi[ii,1])/(yn)))*(hi[ii,1]-
yn)*ab*hi[ii,2])→eq2[ii,1]
EndFor
Disp "eq1:",eq1
Disp "eq2:",eq2
Disp "solution",solve(eq1[1,1]=n and eq2[1,1]=mf+n(0.5*h+yn),{yn,σ})|yn>0
EndPrgm
但是我得到了"Error: Variable is not defined"
我不明白为什么会收到此错误,我在做什么错? 任何提示将不胜感激,这是我的编程新手。
答案 0 :(得分:0)
已解决:问题出在局部变量定义中。
Define LibPub bj_semi_rgd_fl()=
Prgm
Local b,h,ab,n,mf,nf,hi,msg,i,j
Request "Larghezza flangia :",b
Request "Lunghezza flangia :",h
Request "Sezione bullone :",ab
Request "N : ",n
Request "Mf : ",mf
Request "N° file sopra A-N : ",nf
hi:=newMat(nf,2)
For i,1,nf,1
Request "altezza della fila i-esima:",msg
hi[i,1]:=msg
Request "bulloni per fila i-esima:",msg
hi[i,2]:=msg
EndFor
eq1:=0
eq2:=0
For j,1,nf,1
eq1:=eq1+−σ*(1-((hi[j,1])/(yn)))*ab*hi[j,2]
eq2:=eq2+−σ*(1-((hi[j,1])/(yn)))*(hi[j,1]-yn)*ab*hi[j,2]
EndFor
Disp "+++Risultato+++"
Disp "",solve(((−b*σ*yn)/(2))+eq1=n and ((b*σ*yn^(2))/(3))+eq2=mf+n*(0.5*h+yn),
{yn,σ})|yn>0
Disp "++++++++++++"
DelVar eq1,eq2,yn,σ
EndPrgm
因此,我刚刚取消了命令“ solve()”中使用的变量。就是这样。