Collecting and Reploting the Multiple Samples that have been taken from a already plotted Graph using the text data files having alot of values
3 次查看(过去 30 天)
显示 更早的评论
i have a program in which ihave collected the sensor data like powers of 6 sectors and time in seconds so in data text file i have total 7 colums and more than 75210000 rows means you can say more than 500hours of data, now what i have to do to plot each sector power against the time on x-axis, already done, now i have to observesome changes within the plot and have to select some random intervals within the graph and have to replot them all together but interval i have to take should be of half hour of duration. So my question is that how to take particular samples within some different intervals using X-axis on which my time has been ploted on X-Axis, and how to program this situation i dont want to use any tool like variables but want to program to take the sample and plot them all toegther so that i can see the comparison in all samples with different time of same duration of intervals . thanks i will be very thanksfull to all your suggestions and advises.
回答(1 个)
Image Analyst
2020-12-8
"i dont want to use any tool like variables" <== huh??? A program with no variables??? Anyway... use randperm() to get two random indexes then extract those segments and plot them. Untested code
t = data(:, 1); % Assuming time/x is in column 1
numberOfSegmentsToPlot = 50; % Whatever you want.
for k = 1 : numberOfSegmentsToPlot
% Get two random indexes:
indexes = sort(randperm(length(t), 2), 'ascend');
% Extract x between those two indexes, inclusive
subx = t(indexes(1) : indexes(2));
% Now get all 6 powers between those two interval endpoints.
for col = 2 : size(data, 2) % For columns 2 to the right edge
% Extract power in column 3 (or whatever) between those two indexes, inclusive
power = data(indexes(1) : indexes(2), 3);
% Plot vs x.
plot(subx, power, '-', 'LineWidth', 1);
% Eliminate subx if you want them all overlapped instead of using actual x values.
% plot(power, '-', 'LineWidth', 1);
hold on;
end
end
grid on;
xlabel('Time', 'FontSize', 16);
ylabel('Power', 'FontSize', 16)
title('Suresh is an awesome dude', 'FontSize', 16); % Whatever you want.
Attach your data and code to read it in if you need more help.
12 个评论
SURESH KUMAR
2020-12-8
Thanks for your answers, i really appreciate your efforts the way you cleared my concept but actually im new here on matlab , i have attached the code and also data file now when you will run it it shows the power of four different sectors in mW in one plot i have to take the segments like for example time in hours goes from 0 to 150hours now i have to program like this way that at 5-5.5, 8-8.5, and 78-78.5 hours of all those samples i have to collect and replot them all on the same time axis but ofcourse this time the range of time axis (x) will be the actual range of sample time like i have collected total of 1.5 hours of different samples each having duration of 0.5 hours , now i have to plot them all toegther. Please if you clearify me i will be so pleased ..
for the moment i have attached data text file for a very short duration , first colum represent no of times samples taken in text file, i want to learn how to do the above situation.
SURESH KUMAR
2020-12-8
meanwhile im also working on your program that you have suggested me so Thanks alot for this one also , i will give you my feedback if it works
Image Analyst
2020-12-8
Can't run your code:
>> paper_C_plotdata_FLUXES_escogido_PAPER_C_Suresh
Unrecognized function or variable 'Number'.
Error in paper_C_plotdata_FLUXES_escogido_PAPER_C_Suresh (line 15)
time_raw =Number;
SURESH KUMAR
2020-12-9
编辑:SURESH KUMAR
2020-12-9
now i have to show the plot somthing like this please see the attachment picture , im doing the matlab coding at very begining level so i need helo from you to make me understand every step thanks alot the way you are teaching me im really pleased and appreciated your effors. although im trying that previous code but still having alot of confusions in the code like t(indexes(1) : indexes(2)); here what should i update in it as per my requirement, and for every segment i have to design one "For loop" ?
SURESH KUMAR
2020-12-9
i have tried your code this way but now outpur yet , as per my undertanding i changed this code but need your help and suggestions for this moment i took only one sample from all four powers as per my understanding
time_raw =Number;
n = length(time_raw);
figure;
for i = 1:n
time1(i)=((time_raw(i)/40000000)*16777216)/3600;
end
%t = data(:, 1); % Assuming time/x is in column 1
numberOfSegmentsToPlot = 1; % Whatever you want.
n1 = length(time1);
for k = 0 : numberOfSegmentsToPlot
% Get two random indexes:
s = sort(randperm(length(time1),2), 'ascend');
% Extract x between those two indexes, inclusive
subx = time1(s(8) : s(9));
% Now get all 6 powers between those two interval endpoints.
for k1=0:numberOfSegmentsToPlot % For columns 2 to the right edge
% Extract power in column 3 (or whatever) between those two indexes, inclusive
px1 = px(s(8) : s(9));
plot(time1, px1, 'r', 'LineWidth', 0.5);
hold on;
py1 = py(s(8) : s(9));
plot(time1, py1, 'r', 'LineWidth', 0.5);
hold on;
pz1 = pz(s(8) : s(9));
plot(time1, pz1, 'r', 'LineWidth', 0.5);
hold on;
pa1 = pa(s(8) : s(9));
plot(time1, pa1, 'r', 'LineWidth', 0.5);
hold on;
end
end
xlabel('time[h]');
ylabel('power per channel [mW]');
grid on;
%xlim([0 6]);
%ylim([0 20]);
SURESH KUMAR
2020-12-9
in addition to the previous information, i have data in text file im importing the data as column vector into the workspace so i have all variables defined in workspace after impoting as column vector
Image Analyst
2020-12-9
I don't see how the randomness is involved in the plot you showed. It just looks like 4 normal plots of all the data.
% To draw vertical lines you can use xline():
xline(yourXValue, 'LineWidth', 2, 'Color', 'r');
% To draw horizontal lines you can use yline():
yline(yourYValue, 'LineWidth', 2, 'Color', 'r');
% To place text on the plot you can use text():
text(yourXValue, yourYValue, 'FontSize', 20, 'FontWeight', 'bold', 'Color', 'r');
SURESH KUMAR
2020-12-9
if you run my code with given data after imporing the plot of power - pow avg vs time(h) will be displayed in fig 1 or 2 now i have to take some sample like for example 2-2.5 hours and 5-5.5 hours and draw them with the new time axis how to do that
Image Analyst
2020-12-9
If you want them to be in a different axes on a different figure for each segment you extract, then put figure in the loop
t = data(:, 1); % Assuming time/x is in column 1
numberOfSegmentsToPlot = 5; % Whatever you want.
for k = 1 : numberOfSegmentsToPlot
% Get two random indexes:
indexes = sort(randperm(length(t), 2), 'ascend');
% Extract x between those two indexes, inclusive
subx = t(indexes(1) : indexes(2));
% Now get all 6 powers between those two interval endpoints.
for col = 2 : size(data, 2) % For columns 2 to the right edge
% Extract power in column 3 (or whatever) between those two indexes, inclusive
power = data(indexes(1) : indexes(2), 3);
% Plot vs x.
figure; % Bring up a completely new figure for this.
plot(subx, power, '-', 'LineWidth', 1);
% Eliminate subx if you want them all overlapped instead of using actual x values.
% plot(power, '-', 'LineWidth', 1);
hold on;
end
end
grid on;
xlabel('Time', 'FontSize', 16);
ylabel('Power', 'FontSize', 16)
title('Suresh is an awesome dude', 'FontSize', 16); % Whatever you want.
SURESH KUMAR
2020-12-11
you code is not making any output, however i have tried this one figure;
McIdx = (time >=8.5 ) & (time <= 10);
%McIdx = (time >=9.3 ) & (time <= 9.8); second sample
%McIdx = (time >=11 ) & (time <= 11.5); 3rd sample
%McIdx = (time >=2) & (time <= 2.5); second sample
% Select Elements (Logical Vector)
plot(time(McIdx), px(McIdx),'r', 'linewidth',.5)
hold on
plot(time(McIdx), py(McIdx),'b', 'linewidth',.5)
% Plot Range
hold on
plot(time(McIdx), pz(McIdx),'m', 'linewidth',.5)
% Plot Range
hold on
plot(time(McIdx), pa(McIdx),'c', 'linewidth',.5)
% Plot Range
hold on
xlabel('time[h]');
ylabel('Power - P_{avg} [mW]');
legend('Location','best');
legend('Ch0(up)','Ch1(down)','Ch3(up)','Ch4(down)');
grid on;
outup:
it shows me one sample in new figure now i want my all four sample in new figure with all together as i sent you in previous comment an example picture of plot that i want how to do that ? in new figure the time on axis should starte from 0- onwards tilll the actucaly time limit of all samples like suppose my sample make a duartion of 5 hours all together, now time on axis 0-5hours using previous time formula that i already have define in whole program that is extarcted from data text file using this formula time=time_raw/.......
SURESH KUMAR
2020-12-11
编辑:SURESH KUMAR
2020-12-11
complete code is this ...
close all;
% j=0;
% k=1;
% m=length(heaterdata);
% Theater=zeros(7173,1);
% for j=1:m
% str=heaterdata(j);
% word=strread(str,'%11s');
% if mod(j,2)== 0
% Theater(k)=str2num(word{2});
% k=k+1;
% end
% end
%time_raw = data{:,1};
time_raw =Number;
n = length(time_raw);
window = 64;
Ihigh = 0.0165;
Ilow = 0.005;
Kcemento=0.4;
PowerCh1=PWMupCh0Ohm;
PowerCh2=PWMupCh1Ohm;
PowerCh3=PWMupCh2Ohm;
PowerCh4=PWMupCh3Ohm;
PowerCh5=PWMupCh4Ohm;
PowerCh6=PWMupCh5Ohm;
Pt1000=Rpt1kOhm;
flux=zeros(n,1);
distance=0.03;
time=zeros(n,1);
PowMeas1=zeros(n,1);
PowMeas2=zeros(n,1);
PowMeas3=zeros(n,1);
PowMeas4=zeros(n,1);
PowMeas5=zeros(n,1);
PowMeas6=zeros(n,1);
PowMeas1n=zeros(n,1);
PowMeas2n=zeros(n,1);
PowMeas3n=zeros(n,1);
PowMeas4n=zeros(n,1);
PowMeas5n=zeros(n,1);
PowMeas6n=zeros(n,1);
Tamb=zeros(n,1);
% PowMeas5=zeros(n,1);
% PowMeas6=zeros(n,1);
% Tempsector1=zeros(n,1);
% Tempsector2=zeros(n,1);
% Tempsector3=zeros(n,1);
% Tempsector4=zeros(n,1);
% Tempsector5=zeros(n,1);
% Tempsector6=zeros(n,1);
period = 31250;
roA=176.5/(1+0.003*21);
roB=179.2578/(1+0.003*21);
roC=172.6640/(1+0.003*21);
ro2A=172.996/(1+0.003*21);
ro2B=189.098/(1+0.003*21);
ro2C=174.5429/(1+0.003*21);
for i = 1:n
time(i)=((time_raw(i)/40000000)*16777216)/3600;
end
PowMeas1= (PowerCh1/period)*100;
PowMeas2= (PowerCh2/period)*100;
PowMeas3= (PowerCh3/period)*100;
PowMeas4= (PowerCh4/period)*100;
PowMeas5= (PowerCh5/period)*100;
PowMeas6= (PowerCh6/period)*100;
Tamb=(Pt1000-1000)/3.85;
Ttarget=(113.367/100-1)/0.00386;
avg=(PowMeas1+PowMeas2+PowMeas4+PowMeas5)/4;
%flux(i)=((Theater(i)-Tamb(i))*Kcemento)/distance;
PowMeas1n=PowMeas1./avg;
PowMeas2n=PowMeas2./avg;
PowMeas3n=PowMeas3./avg;
PowMeas4n=PowMeas4./avg;
PowMeas5n=PowMeas5./avg;
PowMeas6n=PowMeas6./avg;
%PowMeas3(i)= (PowerCh3(i)/period)*100;
% PowMeas5(i)= (PowerCh5(i)/period)*100;
% PowMeas6(i)= (PowerCh6(i)/period)*100;
% Tempsector1(i)=((ResCh1(i)/roA-1)/0.003);
% Tempsector2(i)=((ResCh2(i)/roB-1)/0.003);
% Tempsector3(i)=((ResCh3(i)/roC-1)/0.003);
% Tempsector4(i)=((ResCh4(i)/ro2A-1)/0.003);
% Tempsector5(i)=((ResCh5(i)/ro2B-1)/0.003);
% Tempsector6(i)=((ResCh6(i)/ro2C-1)/0.003);
convP1 = conv(PowMeas1, ones(1, window)/window, 'same');
convP2 = conv(PowMeas2, ones(1, window)/window, 'same');
convP3 = conv(PowMeas3, ones(1, window)/window, 'same');
convP4 = conv(PowMeas4, ones(1, window)/window, 'same');
convP5 = conv(PowMeas5, ones(1, window)/window, 'same');
convP6 = conv(PowMeas6, ones(1, window)/window, 'same');
convPn1 = conv(PowMeas1n, ones(1, window)/window, 'same');
convPn2 = conv(PowMeas2n, ones(1, window)/window, 'same');
convPn3 = conv(PowMeas3n, ones(1, window)/window, 'same');
convPn4 = conv(PowMeas4n, ones(1, window)/window, 'same');
convPn5 = conv(PowMeas5n, ones(1, window)/window, 'same');
convPn6 = conv(PowMeas6n, ones(1, window)/window, 'same');
convPt = conv(Tamb, ones(1, window)/window, 'same');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Imax=16.5e-3;
Imin=5e-3;
Rtarget=113.367;
P1=Imin^2*Rtarget*(100-convP1)/100+Imax^2*Rtarget*convP1/100;
P2=Imin^2*Rtarget*(100-convP2)/100+Imax^2*Rtarget*convP2/100;
P4=Imin^2*Rtarget*(100-convP4)/100+Imax^2*Rtarget*convP4/100;
P5=Imin^2*Rtarget*(100-convP5)/100+Imax^2*Rtarget*convP5/100;
Off=(P1+P2+P4+P5)/4;
figure;
plot(time,(P1-Off)*1000,'r', 'linewidth',.5)
hold on;
plot(time,(P2-Off)*1000,'b', 'linewidth',.5)
hold on;
%plot(time_good,convP3_good./O,'g', 'linewidth',.5)
hold on;
plot(time,(P4-Off)*1000,'m', 'linewidth',.5)
hold on;
plot(time,(P5-Off)*1000,'c', 'linewidth',.5)
hold on;
%plot(time_good,convP6_good./O,'y', 'linewidth',.5)
xlabel('time[h]');
ylabel('Power - P_{avg} [mW]');
legend('Location','best');
legend('Ch0(up)','Ch1(down)','Ch3(up)','Ch4(down)');
grid on;
%xlim([0 6]);
%figure;plot(hf);grid on
figure;
plot(time,(Off)*1000,'k', 'linewidth',.5)
xlabel('time[h]');
ylabel('P_{avg} [mW]');
grid on;
%xlim([0 6]);
ylim([0 20]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%n20=4;n30_8=n20;n81=n30_8;
%while time(n20)<20
% n20=n20+1;
%end
%while time(n30_8)<30.8
% n30_8=n30_8+1;
%end
%while time(n81)<80.8
% n81=n81+1;
%end
O=1/4*(convP1+convP2+convP4+convP5);
P0=convP1-O;
P1=convP2-O;
P3=convP4-O;
P4=convP5-O;
hf_estimator=(P0+P1).^2+(P3+P4).^2+(P0-P1).^2+(P3-P4).^2;
figure;plot(time,hf_estimator);grid on;ylim([0,1000]);
figure;plot(time,O);grid on
Imax=16.5e-3;
Imin=5e-3;
Rtarget=113.367;
P1=Imin^2*Rtarget*(100-convP1)/100+Imax^2*Rtarget*convP1/100;
P2=Imin^2*Rtarget*(100-convP2)/100+Imax^2*Rtarget*convP2/100;
P4=Imin^2*Rtarget*(100-convP4)/100+Imax^2*Rtarget*convP4/100;
P5=Imin^2*Rtarget*(100-convP5)/100+Imax^2*Rtarget*convP5/100;
Off=(P1+P2+P4+P5)/4;
figure;subplot(2,1,1);
plot(time,(P1-Off)*1000,'r', 'linewidth',.5)
hold on;
plot(time,(P2-Off)*1000,'b', 'linewidth',.5)
hold on;
%plot(time_good,convP3_good./O,'g', 'linewidth',.5)
hold on;
plot(time,(P4-Off)*1000,'m', 'linewidth',.5)
hold on;
plot(time,(P5-Off)*1000,'c', 'linewidth',.5)
hold on;
%plot(time_good,convP6_good./O,'y', 'linewidth',.5)
xlabel('time[h]');
ylabel('Power - P_{avg} [mW]');
legend('Location','best');
legend('Ch0(up)','Ch1(down)','Ch3(up)','Ch4(down)');
grid on;
%xlim([0 6]);
%figure;plot(hf);grid on
subplot(2,1,2);
plot(time,(Off)*1000*4,'k', 'linewidth',.5)
xlabel('time[h]');
ylabel('Total power of sphere [mW]');
grid on;
%xlim([0 6]);
%ylim([0 20]);
px=(P1-Off)*1000;
py=(P2-Off)*1000;
pz=(P4-Off)*1000;
pa=(P5-Off)*1000;
figure;
McIdx = (time >=8.5 ) & (time <= 10);
%McIdx = (time >=9.3 ) & (time <= 9.8); second sample
%McIdx = (time >=11 ) & (time <= 11.5); 3rd sample
%McIdx = (time >=2) & (time <= 2.5); second sample
% Select Elements (Logical Vector)
plot(time(McIdx), px(McIdx),'r', 'linewidth',.5)
hold on
plot(time(McIdx), py(McIdx),'b', 'linewidth',.5)
% Plot Range
hold on
plot(time(McIdx), pz(McIdx),'m', 'linewidth',.5)
% Plot Range
hold on
plot(time(McIdx), pa(McIdx),'c', 'linewidth',.5)
% Plot Range
hold on
xlabel('time[h]');
ylabel('Power - P_{avg} [mW]');
legend('Location','best');
legend('Ch0(up)','Ch1(down)','Ch3(up)','Ch4(down)');
grid on;
%Kr=px-pz/25;
%%%%%%%%%%%%%%%%%%%%%
figure;
%t = data(:, 1); % Assuming time/x is in column 1
numberOfSegmentsToPlot = 1; % Whatever you want.
n1 = length(time1);
for k = 0 : numberOfSegmentsToPlot
% Get two random indexes:
s = sort(randperm(length(time1),2), 'ascend');
% Extract x between those two indexes, inclusive
subx = time1(s(8) : s(9));
% Now get all 6 powers between those two interval endpoints.
for k1=0:numberOfSegmentsToPlot % For columns 2 to the right edge
% Extract power in column 3 (or whatever) between those two indexes, inclusive
px1 = px(s(8) : s(9));
% Plot vs x.
plot(px1, 'r', 'LineWidth', 0.5);
% Eliminate subx if you want them all overlapped instead of using actual x values.
% plot(power, '-', 'LineWidth', 1);
hold on;
end
end
xlabel('time[h]');
ylabel('power per channel [mW]');
grid on;
%xlim([0 6]);
%ylim([0 20]);
%%%%%%%%%%%%%%%
close all;
% j=0;
% k=1;
% m=length(heaterdata);
% Theater=zeros(7173,1);
% for j=1:m
% str=heaterdata(j);
% word=strread(str,'%11s');
% if mod(j,2)== 0
% Theater(k)=str2num(word{2});
% k=k+1;
% end
% end
%time_raw = data{:,1};
time_raw =Number;
n = length(time_raw);
window = 64;
Ihigh = 0.0165;
Ilow = 0.005;
Kcemento=0.4;
PowerCh1=PWMupCh0Ohm;
PowerCh2=PWMupCh1Ohm;
PowerCh3=PWMupCh2Ohm;
PowerCh4=PWMupCh3Ohm;
PowerCh5=PWMupCh4Ohm;
PowerCh6=PWMupCh5Ohm;
Pt1000=Rpt1kOhm;
flux=zeros(n,1);
distance=0.03;
time=zeros(n,1);
PowMeas1=zeros(n,1);
PowMeas2=zeros(n,1);
PowMeas3=zeros(n,1);
PowMeas4=zeros(n,1);
PowMeas5=zeros(n,1);
PowMeas6=zeros(n,1);
PowMeas1n=zeros(n,1);
PowMeas2n=zeros(n,1);
PowMeas3n=zeros(n,1);
PowMeas4n=zeros(n,1);
PowMeas5n=zeros(n,1);
PowMeas6n=zeros(n,1);
Tamb=zeros(n,1);
% PowMeas5=zeros(n,1);
% PowMeas6=zeros(n,1);
% Tempsector1=zeros(n,1);
% Tempsector2=zeros(n,1);
% Tempsector3=zeros(n,1);
% Tempsector4=zeros(n,1);
% Tempsector5=zeros(n,1);
% Tempsector6=zeros(n,1);
period = 31250;
roA=176.5/(1+0.003*21);
roB=179.2578/(1+0.003*21);
roC=172.6640/(1+0.003*21);
ro2A=172.996/(1+0.003*21);
ro2B=189.098/(1+0.003*21);
ro2C=174.5429/(1+0.003*21);
for i = 1:n
time(i)=((time_raw(i)/40000000)*16777216)/3600;
end
PowMeas1= (PowerCh1/period)*100;
PowMeas2= (PowerCh2/period)*100;
PowMeas3= (PowerCh3/period)*100;
PowMeas4= (PowerCh4/period)*100;
PowMeas5= (PowerCh5/period)*100;
PowMeas6= (PowerCh6/period)*100;
Tamb=(Pt1000-1000)/3.85;
Ttarget=(113.367/100-1)/0.00386;
avg=(PowMeas1+PowMeas2+PowMeas4+PowMeas5)/4;
%flux(i)=((Theater(i)-Tamb(i))*Kcemento)/distance;
PowMeas1n=PowMeas1./avg;
PowMeas2n=PowMeas2./avg;
PowMeas3n=PowMeas3./avg;
PowMeas4n=PowMeas4./avg;
PowMeas5n=PowMeas5./avg;
PowMeas6n=PowMeas6./avg;
%PowMeas3(i)= (PowerCh3(i)/period)*100;
% PowMeas5(i)= (PowerCh5(i)/period)*100;
% PowMeas6(i)= (PowerCh6(i)/period)*100;
% Tempsector1(i)=((ResCh1(i)/roA-1)/0.003);
% Tempsector2(i)=((ResCh2(i)/roB-1)/0.003);
% Tempsector3(i)=((ResCh3(i)/roC-1)/0.003);
% Tempsector4(i)=((ResCh4(i)/ro2A-1)/0.003);
% Tempsector5(i)=((ResCh5(i)/ro2B-1)/0.003);
% Tempsector6(i)=((ResCh6(i)/ro2C-1)/0.003);
convP1 = conv(PowMeas1, ones(1, window)/window, 'same');
convP2 = conv(PowMeas2, ones(1, window)/window, 'same');
convP3 = conv(PowMeas3, ones(1, window)/window, 'same');
convP4 = conv(PowMeas4, ones(1, window)/window, 'same');
convP5 = conv(PowMeas5, ones(1, window)/window, 'same');
convP6 = conv(PowMeas6, ones(1, window)/window, 'same');
convPn1 = conv(PowMeas1n, ones(1, window)/window, 'same');
convPn2 = conv(PowMeas2n, ones(1, window)/window, 'same');
convPn3 = conv(PowMeas3n, ones(1, window)/window, 'same');
convPn4 = conv(PowMeas4n, ones(1, window)/window, 'same');
convPn5 = conv(PowMeas5n, ones(1, window)/window, 'same');
convPn6 = conv(PowMeas6n, ones(1, window)/window, 'same');
convPt = conv(Tamb, ones(1, window)/window, 'same');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Imax=16.5e-3;
Imin=5e-3;
Rtarget=113.367;
P1=Imin^2*Rtarget*(100-convP1)/100+Imax^2*Rtarget*convP1/100;
P2=Imin^2*Rtarget*(100-convP2)/100+Imax^2*Rtarget*convP2/100;
P4=Imin^2*Rtarget*(100-convP4)/100+Imax^2*Rtarget*convP4/100;
P5=Imin^2*Rtarget*(100-convP5)/100+Imax^2*Rtarget*convP5/100;
Off=(P1+P2+P4+P5)/4;
figure;
plot(time,(P1-Off)*1000,'r', 'linewidth',.5)
hold on;
plot(time,(P2-Off)*1000,'b', 'linewidth',.5)
hold on;
%plot(time_good,convP3_good./O,'g', 'linewidth',.5)
hold on;
plot(time,(P4-Off)*1000,'m', 'linewidth',.5)
hold on;
plot(time,(P5-Off)*1000,'c', 'linewidth',.5)
hold on;
%plot(time_good,convP6_good./O,'y', 'linewidth',.5)
xlabel('time[h]');
ylabel('Power - P_{avg} [mW]');
legend('Location','best');
legend('Ch0(up)','Ch1(down)','Ch3(up)','Ch4(down)');
grid on;
%xlim([0 6]);
%figure;plot(hf);grid on
figure;
plot(time,(Off)*1000,'k', 'linewidth',.5)
xlabel('time[h]');
ylabel('P_{avg} [mW]');
grid on;
%xlim([0 6]);
ylim([0 20]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%n20=4;n30_8=n20;n81=n30_8;
%while time(n20)<20
% n20=n20+1;
%end
%while time(n30_8)<30.8
% n30_8=n30_8+1;
%end
%while time(n81)<80.8
% n81=n81+1;
%end
O=1/4*(convP1+convP2+convP4+convP5);
P0=convP1-O;
P1=convP2-O;
P3=convP4-O;
P4=convP5-O;
hf_estimator=(P0+P1).^2+(P3+P4).^2+(P0-P1).^2+(P3-P4).^2;
figure;plot(time,hf_estimator);grid on;ylim([0,1000]);
figure;plot(time,O);grid on
Imax=16.5e-3;
Imin=5e-3;
Rtarget=113.367;
P1=Imin^2*Rtarget*(100-convP1)/100+Imax^2*Rtarget*convP1/100;
P2=Imin^2*Rtarget*(100-convP2)/100+Imax^2*Rtarget*convP2/100;
P4=Imin^2*Rtarget*(100-convP4)/100+Imax^2*Rtarget*convP4/100;
P5=Imin^2*Rtarget*(100-convP5)/100+Imax^2*Rtarget*convP5/100;
Off=(P1+P2+P4+P5)/4;
figure;subplot(2,1,1);
plot(time,(P1-Off)*1000,'r', 'linewidth',.5)
hold on;
plot(time,(P2-Off)*1000,'b', 'linewidth',.5)
hold on;
%plot(time_good,convP3_good./O,'g', 'linewidth',.5)
hold on;
plot(time,(P4-Off)*1000,'m', 'linewidth',.5)
hold on;
plot(time,(P5-Off)*1000,'c', 'linewidth',.5)
hold on;
%plot(time_good,convP6_good./O,'y', 'linewidth',.5)
xlabel('time[h]');
ylabel('Power - P_{avg} [mW]');
legend('Location','best');
legend('Ch0(up)','Ch1(down)','Ch3(up)','Ch4(down)');
grid on;
%xlim([0 6]);
%figure;plot(hf);grid on
subplot(2,1,2);
plot(time,(Off)*1000*4,'k', 'linewidth',.5)
xlabel('time[h]');
ylabel('Total power of sphere [mW]');
grid on;
%xlim([0 6]);
%ylim([0 20]);
px=(P1-Off)*1000;
py=(P2-Off)*1000;
pz=(P4-Off)*1000;
pa=(P5-Off)*1000;
figure;
McIdx = (time >=8.5 ) & (time <= 10);
%McIdx = (time >=9.3 ) & (time <= 9.8); second sample
%McIdx = (time >=11 ) & (time <= 11.5); 3rd sample
%McIdx = (time >=2) & (time <= 2.5); second sample
% Select Elements (Logical Vector)
plot(time(McIdx), px(McIdx),'r', 'linewidth',.5)
hold on
plot(time(McIdx), py(McIdx),'b', 'linewidth',.5)
% Plot Range
hold on
plot(time(McIdx), pz(McIdx),'m', 'linewidth',.5)
% Plot Range
hold on
plot(time(McIdx), pa(McIdx),'c', 'linewidth',.5)
% Plot Range
hold on
xlabel('time[h]');
ylabel('Power - P_{avg} [mW]');
legend('Location','best');
legend('Ch0(up)','Ch1(down)','Ch3(up)','Ch4(down)');
grid on;
%Kr=px-pz/25;
%%%%%%%%%%%%%%%%%%%%%
figure;
%t = data(:, 1); % Assuming time/x is in column 1
numberOfSegmentsToPlot = 1; % Whatever you want.
n1 = length(time1);
for k = 0 : numberOfSegmentsToPlot
% Get two random indexes:
s = sort(randperm(length(time1),2), 'ascend');
% Extract x between those two indexes, inclusive
subx = time1(s(8) : s(9));
% Now get all 6 powers between those two interval endpoints.
for k1=0:numberOfSegmentsToPlot % For columns 2 to the right edge
% Extract power in column 3 (or whatever) between those two indexes, inclusive
px1 = px(s(8) : s(9));
% Plot vs x.
plot(px1, 'r', 'LineWidth', 0.5);
% Eliminate subx if you want them all overlapped instead of using actual x values.
% plot(power, '-', 'LineWidth', 1);
hold on;
end
end
xlabel('time[h]');
ylabel('power per channel [mW]');
grid on;
%xlim([0 6]);
%ylim([0 20]);
%%%%%%%%%%%%%%%
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Plot Customization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)