How do I plot different array smoothly which contain NaN in same figure
이전 댓글 표시
Plot 4 arrays all of them contain NaN value. How do you plot it smoothly.
Here is the code:
lw=2
plot(Sig1,'LineWidth',lw,'Color',[1 0.76 0])
hold on
plot(Sig2,'r','LineWidth',lw)
hold on
plot(Sig3,'g','LineWidth',lw)
hold on
plot(Sig4,'b','LineWidth',lw)
hold off
답변 (1개)
Star Strider
2020년 7월 4일
Example —
sig1 = [rand(1,10) NaN];
sig2 = [rand(1,10) NaN];
sig3 = [rand(1,10) NaN NaN];
sig4 = [rand(1,10) NaN];
sigv = [sig1 sig2 sig3 sig4];
sigvfm = fillmissing(sigv, 'linear');
figure
plot(sigv, 'b', 'LineWidth',1.5)
hold on
plot(sigvfm,'r')
hold off.
Make appropriate changes to work with your data.
.
댓글 수: 6
Md Hassanuzzaman
2020년 7월 5일
Star Strider
2020년 7월 5일
Try this:
D = load('sig.mat');
Sig1 = D.Sig1;
Sig2 = D.Sig2;
Sig3 = D.Sig3;
Sig4 = D.Sig4;
Sig = [Sig1,Sig2,Sig3,Sig4];
Sigfm = fillmissing(Sig, 'linear', 'EndValues','nearest');
figure
subplot(2,1,1)
plot(Sig, 'LineWidth',1)
subplot(2,1,2)
plot(Sigfm, 'LineWidth',1)
producing:

There are a number of options that specify how fillmissing should work. Explore that documentaiton to see what works best for you.
Md Hassanuzzaman
2020년 7월 6일
Star Strider
2020년 7월 6일
Much of this is ambiguous.
Try this:
D = load('sig.mat');
Sig1 = D.Sig1;
Sig2 = D.Sig2;
Sig3 = D.Sig3;
Sig4 = D.Sig4;
Sig = [Sig1;Sig2;Sig3;Sig4]; % Concatenate
Sigfm = fillmissing(Sig, 'linear', 'EndValues','nearest'); % Fill NaN Values
figure
plot(Sigfm(1,:), 'k', 'LineWidth',1)
producing:

.
Md Hassanuzzaman
2022년 6월 8일
Star Strider
2022년 6월 8일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!