plotting help with loop and complex matrix

4 Ansichten (letzte 30 Tage)
neil whitesell
neil whitesell am 22 Nov. 2020
Kommentiert: neil whitesell am 30 Nov. 2020
i am trying to save values from the 50th slice of matrix of 101 (one value to the left of the center), which is spit out by this 'pfield' program, and graph them with the variable i have listed as 'imp"
im just having trouble figuring out how to save only the one value, curr and the 'imp' from each loop so i can plot the relation at the end
the program 'pfield' works prefectly, so i'm not worried about that, just trying to get the variable 'cur' on one axis and 'imp' on the othe
(the matrix pfield spits out is complex, thats why there is 'abs' in there)
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

Antworten (1)

Srivardhan Gadila
Srivardhan Gadila am 29 Nov. 2020
Store the output of the function pfield in a variable and use it. You can try changing your for loop code as follows:
cur = [];
for a=.00002:.00001:.01
curOut = pfield(l,a,E,ker,basis);
cur = [cur abs(curOut(50))];
end
imp = 100./cur;
plot(imp,cur);
Refer to the documentation of function.

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by