matlabにおいて、さまざまなコイル位置での周波数に対するインピーダンスとインダクタンスの曲線を図に示したいのですが、グラフ表示がうまくできません。下の画像を見たら、値の入っていない変数があります。どういう風にしたら、値が入るのでしょうか、リンク内容と同じコードです。
matlab
1% Base problem name and configuration 2myFile='SSF-082.fem'; 3myCoilName='Icoil'; 4myCoilGroup=1; 5 6% Displacement range under consideration 7xmin=-15; 8xmax=15; 9dx=5; 10 11% Frequency range under consideration. 12wmin = 0; % 10^0 = 1 Hz 13wmax = 4; % 10^4 = 10000 Hz 14dw = 1/5; % 5 points per decade on a log scale 15% Open up base problem and save as the DC operating point with no coil current 16openfemm; 17opendocument(myFile); 18mi_setcurrent(myCoilName,0); 19mi_saveas('DCProblem.fem'); 20 21 22% Open up base problem and save as the incremental AC problem with a coil current of 1A 23% Incremental AC problem points back to the DC solution via the mi_setprevious('DCProblem.ans') call 24opendocument(myFile); 25mi_setcurrent(myCoilName,1); 26mi_setprevious('DCProblem.ans'); 27mi_saveas('ACProblem.fem'); 28 29% move the coil to the xmin position, assuming that the geometry is drawn so that the coil is nominally at x=0 30mi_setfocus('DCProblem.fem'); 31mi_selectgroup(myCoilGroup); 32mi_movetranslate(0,xmin); 33mi_setfocus('ACProblem.fem'); 34mi_selectgroup(myCoilGroup); 35mi_movetranslate(0,xmin); 36 37% Step through the full range of coil positions 38Lx=[]; 39Vx=[]; 40Bl=[]; 41Lo=[]; 42Xx=xmin:dx:xmax; 43Ww=10.^(wmin:dw:wmax); 44 45for x=xmin:dx:xmax 46 Lfd=[]; 47 Vfd=[]; 48 mi_setfocus('DCProblem.fem'); 49 mi_analyze(); 50 51 % Get inductance in the limiting case as frequency goes to zero 52 mi_setfocus('ACProblem.fem'); 53 mi_probdef(10^(-6)); 54 mi_analyze(); 55 mi_loadsolution(); 56 u=mo_getcircuitproperties(myCoilName); 57 Lo=[Lo, abs(u(3))]; 58 59 % At each coil position, evaluate Bl and coil inductance over a range of frequencies 60 for k=wmin:dw:wmax 61 mi_setfocus('ACProblem.fem'); 62 mi_probdef(10^k); 63 mi_analyze(); 64 mi_loadsolution(); 65 % Get Bl 66 if (k==0) 67 mo_groupselectblock(1); 68 f=abs(mo_blockintegral(29)); 69 Bl=[Bl, f]; 70 end 71 % Get Inductance and Voltage 72 u=mo_getcircuitproperties(myCoilName); 73 Lfd=[Lfd, u(3)]; 74 Vfd=[Vfd, u(2)]; 75 fprintf('%g %g %s\n',x,10^k,num2str(u(3))); 76 end 77 Lx=[Lx; Lfd]; 78 Vx=[Vx; Vfd]; 79 if (x<xmax) 80 mi_setfocus('DCProblem.fem'); 81 mi_selectgroup(myCoilGroup); 82 mi_movetranslate(0,dx); 83 mi_setfocus('ACProblem.fem'); 84 mi_selectgroup(myCoilGroup); 85 mi_movetranslate(0,dx); 86 end 87end 88closefemm; 89 90% Plot up some results 91figure(1); 92loglog(Ww,abs(Vx)); 93xlabel('Frequency, Hz'); 94ylabel('Impedance, Ohms'); 95title('Impedance vs. Frequency and Position'); 96 97figure(2); 98loglog(Ww,abs(1000*Lx)); 99xlabel('Frequency, Hz'); 100ylabel('Inductance, mH'); 101title('Inductance vs. Frequency and Position'); 102 103 104figure(3); 105plot(Xx,Bl); 106xlabel('Frequency, Hz') 107ylabel('B*l, N/A, Ohms') 108title('B*l vs. Frequency and Position')
あなたの回答
tips
プレビュー