フィルターのクリア

need plotting help with matrix and loops

3 ビュー (過去 30 日間)
neil whitesell
neil whitesell 2020 年 11 月 23 日
コメント済み: neil whitesell 2020 年 11 月 30 日
i have a program that spits out a 101 row complex matrix, but i need to retrieve only the 50th row (one less than the 'middle') and save it into the plot, then re-do the loop to gather the same vallue with a different variable each time, to plot the change in the result. i am new to matlab and need some help fixing this error please
the variable i am snatching is 'cur' and i'd like to plot it on y axis with 'imp' on the x-axis.
(if you're curious this is an antenna program to graph the impedance and current as the 'thickness' of the antenna changes)
close all
clc
addpath c:\antennas\ewa;
l=.68;
a=(.00002);
ker='a';
basis='d';
E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
x=(0:1:100);
for a=.00002:.00001:.01
pfield(l,a,E,ker,basis);
cur=abs(ans(50))
imp=100/cur
plot(imp,cur);
hold on
end
hold off
  1 件のコメント
neil whitesell
neil whitesell 2020 年 11 月 23 日
the pfield() program spits out a complex matrix of the same size as the input 'E', the bit where i specify 'ans' is the output of that pprogram

サインインしてコメントする。

回答 (1 件)

Rohit Pappu
Rohit Pappu 2020 年 11 月 26 日
Minor refactoring of the above code
close all
clc
clf %%Clear the figure window
addpath c:\antennas\ewa;
l=.68;
a=(.00002);
ker='a';
basis='d';
E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
x=(0:1:100);
hold on
for a=.00002:.00001:.01
output = pfield(l,a,E,ker,basis); %% Using ans in a script is not a good idea
cur=abs(output(50));
imp=100/cur;
plot(imp,cur,'Marker','*'); %% Plots each point as an asterix *
end
hold off
  1 件のコメント
neil whitesell
neil whitesell 2020 年 11 月 30 日
very good answer, thank you

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by