Plotting with a for loop
Afficher commentaires plus anciens
I have a for loop and need to plot my final results. I have the hold on command in my code, but I still get only one point on my plot. What am I doing wrong?
Réponse acceptée
Plus de réponses (4)
Esther Maria Ribezzo
le 13 Mai 2020
0 votes
I have the same problem!!
for i=1:length(asse_x);
MLSE=(norm(AI_concatenated-(S*(A_TOT(:,i))))).^2;
plot(asse_x(i),MLSE, '*')
hold on
end
Moh'd Allouzi
le 13 Juin 2021
0 votes
for k = 1:n
x(k) = k;
y(k) = sin(x(k));
end
figure(1)
plot(x, y)
alaa sleem
le 4 Jan 2022
0 votes
cp=1.2
ta=30
hhv=50000
tex=130
k=1
for lamda =(.8,.1,1.5)
A_F(k)=lamda*x*(32+3.76*28)/(n*12+m*1)
if lamda < 1
N_CO2= x*((2*lamda)-1)-(m/4);
n_CO= x*((2*lamda)-1)-(m/4);
n_h2o=m/2;
n_n2=(lamda*x*3.76);
Total=N_CO2+n_CO+n_n2+n_h2o;
Xi_co2(k)=N_CO2/Total;
Xi__CO(k)=n_CO/Total;
Xi_h2o(k)=n_h2o/Total;
Xi_N2(k)=n_n2/Total;
#______________________________________________lean_____________________________________________
else lamda >= 1
N_CO2= n;
n_O2= x*(lamda-1);
n_h2o=m/2;
n_n2=(lamda*x*3.76);
Total=N_CO2+n_O2+n_n2+n_h2o;
Xi_co2(k)=N_CO2/Total;
Xi_o2(k)=n_O2/Total;
Xi_h2o(k)=n_h2o/Total;
Xi_N2(k)=n_n2/Total;
end
t_f(k) = ta+(hhv/((1+lamda)*cp))
eta(k)= ((1+lamda)*cp*(t_f-tex))/hhv
lamd_list(k)=lamda
k=k+1
end
fig1 = figure(1);
ax1 = axes('Parent', fig1);
A_F_plot = plot(lamd_list, total_util);
%concentration
plot(lamd_list,Xi_co2)
hold.on
plot(lamd_list(:lenght(Xi_o2)),Xi_o2)
hold.on
plot(lamd_list(:lenght(Xi__CO)),Xi__CO)
hold.on
plot(lamd_list,Xi_h2o)
hold.on
plot(lamd_list,Xi_N2)
hold.off
%air fuel
plot(lamd_list,A_F)
%temp
plot(lamd_list,A_F)
I can't seem to get this plot to work. It only pot a single point. How can I make it plot multiple points? I probably need a for loop but I don't know how to use it here. Thanks!
% Calculate PAE for a Time-Varying Complex Baseband Signal
Pdc = 10; % DC input power in watts
Gain_dB = 15; % Power amplifier gain in dB
% Convert gain from dB to linear scale
Gain = 10^(Gain_dB/10);
% Define the time vector and the baseband complex signal parameters
t = linspace(0, 1, 1000); % Time vector from 0 to 1 second
wc = 2*pi*10; % Carrier frequency in radians per second
% Define the time-varying envelope function (you can change this function as needed)
a_t = 1 + 0.5*sin(2*pi*5*t); % Amplitude envelope with variations over time
% Define the phase modulation function (you can change this function as needed)
phi_t = pi/4 * sin(2*pi*t); % Phase modulation with variations over time
% Generate the baseband complex signal x(t) = a(t) * exp(j*(wc*t + phi(t)))
x_t = a_t .* exp(1j*(wc*t + phi_t));
% Calculate the power of the baseband signal
P_baseband = sum(abs(x_t).^2) / length(x_t); % Average power of the signal
% Calculate the RF output power using the power amplifier gain
Pout = P_baseband * Gain;
% Calculate the Power Added Efficiency (PAE) using the formula: PAE = (Pout - Pdc) / Pdc * 100
PAE = (Pout - Pdc) / Pdc * 100;
% Display the PAE value
fprintf('Power Added Efficiency (PAE) = %.3f%%\n', PAE);
% Plot the PAE against the RF output power
figure(6)
plot(Pout, PAE, '-o','LineWidth', 2);
xlabel('RF Output Power (Pout) in Watts');
ylabel('Power Added Efficiency (PAE) in %');
title('PAE vs. Output Power for Time-Varying Complex Baseband Signal');
grid on;
Catégories
En savoir plus sur Spectral Measurements dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
