|
發(fā)布時(shí)間: 2023-3-22 17:31
正文摘要:matlab代碼如下 對兩份代碼我已經(jīng)檢查了幾遍,沒發(fā)現(xiàn)有什么不一樣的地方,但最終的結(jié)果確是不同。 希望大佬幫助!這個圖是我作業(yè),要到期了,嗚嗚。 二樓放源代碼。 |
看不懂mathmatica的代碼,但建議對比兩個軟件算出來的T1~T7,M1~M7,先確定問題發(fā)生的位置 |
mathematica代碼 T1z2018 = Range[5000]; T2z2018 = Range[5000]; T3z2018 = Range[5000]; T4z2018 = Range[5000]; T5z2018 = Range[5000]; For[p = 1, p < 5000, p++, w = 0.001*p; T0 = {{2 - (w^2), -1}, {1, 0}}; T1 = {{(2.5 - (w^2))/1.5, -(1/1.5)}, {1, 0}}; T2 = {{2 - ((w^2)/3), -1}, {1, 0}}; T4 = {{(4.5 - (0.5*(w^2)))/3, -1.5/3}, {1, 0}}; T5 = {{(4.5 - (0.5*(w^2)))/1.5, -3/1.5}, {1, 0}}; T6 = {{2 - ((w^2)/1.5), -1}, {1, 0}}; T7 = {{(6 - (0.5*(w^2)))/3, -1}, {1, 0}}; T3 = {{(2.5 - (w^2))/1, -1.5/1}, {1, 0}}; sigema = 1 - ((w^2)/2) - (I*w*((1 - ((w^2)/4))^(1/2)));(*假設(shè)它不加1*) gamma = w*((1 - ((w^2)/4))^(1/2)); T2={{2-((w^2)/3),-1},{1,0}}; T4={{(4.5-(0.5*(w^2)))/1.5,-3/1.5},{1,0}}; T5={{(4.5-(0.5*(w^2)))/3,-1.5/3},{1,0}}; T6={{2-((w^2)/1.5),-1},{1,0}}; T7={{(6-(0.5*(w^2)))/3,-1},{1,0}}; T3={{(2.5-(w^2))/1.5,-1/1.5},{1,0}};*) M7 = T1.T2.T3;(*I鏈子*) M7 = MatrixPower[M7, 1]; M6 = T1.T2.T6.T2.T3; M6 = MatrixPower[M6, 1];(*III鏈子*) M3 = T1.T4.T5.T3;(*II鏈子*) M4 = T1.T4.T7.T5.T3; M3 = MatrixPower[M3, 1]; M4 = MatrixPower[M4, 1]; M5 = T1.T2.T6.T4.T5.T3;(*V鏈子*) T1z2018[[p]] = 4*(gamma^2)*((Abs[ M7[[1, 1]] - (sigema*(M7[[2, 1]] - M7[[1, 2]])) + (sigema^2)*(-M7[[2, 2]])])^(-2)); T2z2018[[p]] = 4*(gamma^2)*((Abs[ M3[[1, 1]] - (sigema*(M3[[2, 1]] - M3[[1, 2]])) + (sigema^2)*(-M3[[ 2, 2]])])^(-2)); T3z2018[[p]] = 4*(gamma^2)*((Abs[ M6[[1, 1]] - (sigema*(M6[[2, 1]] - M6[[1, 2]])) + (sigema^2)*(-M6[[2, 2]])])^(-2)); T4z2018[[p]] = 4*(gamma^2)*((Abs[ M4[[1, 1]] - (sigema*(M4[[2, 1]] - M4[[1, 2]])) + (sigema^2)*(-M4[[2, 2]])])^(-2)); T5z2018[[p]] = 4*(gamma^2)*((Abs[ M5[[1, 1]] - (sigema*(M5[[2, 1]] - M5[[1, 2]])) + (sigema^2)*(-M5[[2, 2]])])^(-2)); ]; p1 = ListPlot[T1z2018[[Range[0, 2000]]], Joined -> True, PlotStyle -> Red] p2 = ListPlot[T2z2018[[Range[0, 2000]]], Joined -> True, PlotStyle -> Green] p3 = ListPlot[T3z2018[[Range[0, 2000]]], Joined -> True, PlotStyle -> Cyan] p4 = ListPlot[T4z2018[[Range[0, 2000]]], Joined -> True, PlotStyle -> Pink] p5 = ListPlot[T5z2018[[Range[0, 2000]]], Joined -> True, PlotStyle -> Black] Show[p1, p2, p3, p4, p5, PlotRange -> All] |
matlab代碼 clear T1z2018=1:1:2000; T2z2018=1:1:2000; T3z2018=1:1:2000; T4z2018=1:1:2000; T5z2018=1:1:2000; gamma=1:1:2000; for p=1:1:2000 w=p*0.001; T1=[2.5- (w^2)/1.5,-(1/1.5);1,0]; T2=[2-((w^2)/3),-1;1,0]; T4=[(4.5-(0.5*(w^2)))/3,-1.5/3;1,0]; T5=[(4.5-(0.5*(w^2)))/1.5, -3/1.5;1,0]; T6=[2 - ((w^2)/1.5), -1;1,0]; T7=[(6 - (0.5*(w^2)))/3, -1;1,0]; T3=[(2.5 - (w^2))/1, -1.5/1;1,0]; sigema=1 - ((w^2)/2) - (1i*w*((1 - ((w^2)/4))^(1/2))); gamma = w*((1 - ((w^2)/4))^(1/2)); M7=T1*T2*T3; M6=T1*T2*T6*T2*T3; M3=T1*T4*T5*T3; M4=T1*T4*T7*T5*T3; M5=T1*T2*T6*T4*T5*T3; T1z2018(p)=4*(gamma^2)*((abs(M7(1,1)-(sigema*(M7(2, 1)-M7(1, 2)))+ (sigema^2)*(-M7(2, 2))))^(-2)); T2z2018(p)=4*(gamma^2)*((abs(M3(1,1)-(sigema*(M3(2, 1)-M3(1, 2)))+ (sigema^2)*(-M3(2, 2))))^(-2)); T3z2018(p)=4*(gamma^2)*((abs(M6(1,1)-(sigema*(M6(2, 1)-M6(1, 2)))+ (sigema^2)*(-M6(2, 2))))^(-2)); T4z2018(p)=4*(gamma^2)*((abs(M4(1,1)-(sigema*(M4(2, 1)-M4(1, 2)))+ (sigema^2)*(-M4(2, 2))))^(-2)); T5z2018(p)=4*(gamma^2)*((abs(M5(1,1)-(sigema*(M5(2, 1)-M5(1, 2)))+ (sigema^2)*(-M5(2, 2))))^(-2)); end plot(1:1:2000,T1z2018) hold on plot(1:1:2000,T2z2018) hold on plot(1:1:2000,T3z2018) hold on plot(1:1:2000,T4z2018) hold on plot(1:1:2000,T5z2018) |