Azzera filtri
Azzera filtri

need plotting help with matrix and loops

3 visualizzazioni (ultimi 30 giorni)
neil whitesell
neil whitesell il 23 Nov 2020
Commentato: neil whitesell il 30 Nov 2020
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 Commento
neil whitesell
neil whitesell il 23 Nov 2020
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

Accedi per commentare.

Risposte (1)

Rohit Pappu
Rohit Pappu il 26 Nov 2020
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

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by