質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Octave

Octaveは、数値解析のための高レベルのプログラミング言語です。主に理工系の技術者・研究者が使用しており、フリーで使うことが可能。線形もしくは非線形問題を数値的に解くCLIを提供します。

MATLAB

MATLABはMathWorksで開発された数値計算や数値の視覚化のための高水準の対話型プログラミング環境です。

Q&A

2回答

748閲覧

matlabでのコイルのインピーダンス表示

ksyiwk

総合スコア24

Octave

Octaveは、数値解析のための高レベルのプログラミング言語です。主に理工系の技術者・研究者が使用しており、フリーで使うことが可能。線形もしくは非線形問題を数値的に解くCLIを提供します。

MATLAB

MATLABはMathWorksで開発された数値計算や数値の視覚化のための高水準の対話型プログラミング環境です。

0グッド

0クリップ

投稿2019/11/27 08:25

編集2019/12/10 03:01

matlabにおいて、さまざまなコイル位置での周波数に対するインピーダンスとインダクタンスの曲線を図に示したいのですが、グラフ表示がうまくできません。下の画像を見たら、値の入っていない変数があります。どういう風にしたら、値が入るのでしょうか、リンク内容と同じコードです。

Matlab

1addpath('c:\femm42\myFile') 2% Base problem name and configuration 3myFile='SSF-082.fem'; 4myCoilName='Icoil'; 5myCoilGroup=1; 6 7% Displacement range under consideration 8xmin=-15; 9xmax=15; 10dx=5; 11 12% Frequency range under consideration. 13wmin = 0; % 10^0 = 1 Hz 14wmax = 4; % 10^4 = 10000 Hz 15dw = 1/5; % 5 points per decade on a log scale 16% Open up base problem and save as the DC operating point with no coil current 17openfemm; 18opendocument(myFile); 19mi_setcurrent(myCoilName,0); 20mi_saveas('DCProblem.fem'); 21 22 23% Open up base problem and save as the incremental AC problem with a coil current of 1A 24% Incremental AC problem points back to the DC solution via the mi_setprevious('DCProblem.ans') call 25opendocument(myFile); 26mi_setcurrent(myCoilName,1); 27mi_setprevious('DCProblem.ans'); 28mi_saveas('ACProblem.fem'); 29 30% move the coil to the xmin position, assuming that the geometry is drawn so that the coil is nominally at x=0 31mi_setfocus('DCProblem.fem'); 32mi_selectgroup(myCoilGroup); 33mi_movetranslate(0,xmin); 34mi_setfocus('ACProblem.fem'); 35mi_selectgroup(myCoilGroup); 36mi_movetranslate(0,xmin); 37 38% Step through the full range of coil positions 39Lx=[]; 40Vx=[]; 41Bl=[]; 42Lo=[]; 43Xx=xmin:dx:xmax; 44Ww=10.^(wmin:dw:wmax); 45 46for x=xmin:dx:xmax 47 Lfd=[]; 48 Vfd=[]; 49 mi_setfocus('DCProblem.fem'); 50 mi_analyze(); 51 52 % Get inductance in the limiting case as frequency goes to zero 53 mi_setfocus('ACProblem.fem'); 54 mi_probdef(10^(-6)); 55 mi_analyze(); 56 mi_loadsolution(); 57 u=mo_getcircuitproperties(myCoilName); 58 Lo=[Lo, abs(u(3))]; 59 60 % At each coil position, evaluate Bl and coil inductance over a range of frequencies 61 for k=wmin:dw:wmax 62 mi_setfocus('ACProblem.fem'); 63 mi_probdef(10^k); 64 mi_analyze(); 65 mi_loadsolution(); 66 % Get Bl 67 if (k==0) 68 mo_groupselectblock(1); 69 f=abs(mo_blockintegral(29)); 70 Bl=[Bl, f]; 71 end 72 % Get Inductance and Voltage 73 u=mo_getcircuitproperties(myCoilName); 74 Lfd=[Lfd, u(3)]; 75 Vfd=[Vfd, u(2)]; 76 fprintf('%g %g %s\n',x,10^k,num2str(u(3))); 77 end 78 Lx=[Lx; Lfd]; 79 Vx=[Vx; Vfd]; 80 if (x<xmax) 81 mi_setfocus('DCProblem.fem'); 82 mi_selectgroup(myCoilGroup); 83 mi_movetranslate(0,dx); 84 mi_setfocus('ACProblem.fem'); 85 mi_selectgroup(myCoilGroup); 86 mi_movetranslate(0,dx); 87 end 88end 89closefemm; 90 91% Plot up some results 92figure(1); 93loglog(Ww,abs(Vx)); 94xlabel('Frequency, Hz'); 95ylabel('Impedance, Ohms'); 96title('Impedance vs. Frequency and Position'); 97 98figure(2); 99loglog(Ww,abs(1000*Lx)); 100xlabel('Frequency, Hz'); 101ylabel('Inductance, mH'); 102title('Inductance vs. Frequency and Position'); 103 104 105figure(3); 106plot(Xx,Bl); 107xlabel('Frequency, Hz') 108ylabel('B*l, N/A, Ohms') 109title('B*l vs. Frequency and Position')

追記 
イメージ説明

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

WathMorks

2019/11/27 08:54

プログラムを一気に流して「できません」ではなく、一つ一つを切り取って、コマンドウィンドウで実行してください。そうすればエラーの箇所が特定できるはずです。
y_waiwai

2019/11/27 13:55

どういう不具合があるのか詳しく説明しましょう。 できません、だけではどーにもなりませんぜ
guest

回答2

0

インストールしてあります。グラフ表示がうまくできなくて困っています。

投稿2019/12/01 08:47

ksyiwk

総合スコア24

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

変数のサイズがループの反復ごとに変更されているようです。高速化する為に事前割り当てを検討してください。

というのは、計算の高速化のためのヒントなので、修正しなくても計算が遅い以外の問題はありません。

そのスクリプトを実行するには、OctaveFEMMというtoolboxをインストールする必要があるみたいですが、ちゃんとインストールしてありますか。

投稿2019/11/29 21:15

Bearded-Ockham

総合スコア430

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ksyiwk

2019/12/01 08:47

インストールしてあります。グラフ表示がうまくできなくて困っています。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問