plotting help with loop and complex matrix

4 次查看(过去 30 天)
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

回答(1 个)

Srivardhan Gadila
Srivardhan Gadila 2020-11-29
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.

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by