Effacer les filtres
Effacer les filtres

need plotting help with matrix and loops

3 vues (au cours des 30 derniers jours)
neil whitesell
neil whitesell le 23 Nov 2020
Commenté : neil whitesell le 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 commentaire
neil whitesell
neil whitesell le 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

Connectez-vous pour commenter.

Réponses (1)

Rohit Pappu
Rohit Pappu le 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
  1 commentaire
neil whitesell
neil whitesell le 30 Nov 2020
very good answer, thank you

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by