b1 = a1(a1 ~= 0);
b2 = a2(a2 ~= 0);
b3 = a3(a3 ~= 0);
b4 = a4(a4 ~= 0);
ind = ~ismissing(b1);
ind1 = ~ismissing(b3)
% load('nameoffile.mat','b1','b2','b3','b4')
%
% save("nameoffile.mat","b1","b2","b3","b4",'-append')
figure(2);
subplot(1,2,1);
drawnow
hAxes = gca;
hold(hAxes,"on");
xlabel('CSI Amp');
ylabel('Keyhole Amp Low Res');
%plot(hAxes,b1(ind),b2(ind));
scatter(b1(ind),b2(ind),'filled')
[R,p] = corrcoef(b1,b2);
R = R(2);
p = p(2);
title(['R =' num2str(R) ', p =' num2str(p)]);
hold(hAxes,"off");
subplot(1,2,2);
drawnow
gAxes = gca;
hold(gAxes,"on");
xlabel('CSI R2M Amp');
ylabel('Keyhole R2M Amp Low Res');
%plot(gAxes,b3(ind1),b4(ind1),'o');
scatter(b3(ind1),b4(ind1),'filled')
[R,p] = corrcoef(b3,b4);
R = R(2);
p = p(2);
title(['R =' num2str(R) ', p =' num2str(p)]);
hold(gAxes,"off");
So I am trying to make two graphs on one tab. The one on the left will work fine, but the one on the right won't work. This only happens for certain sets of data when there is a NaN in the selected set. I used the "ind = ~ismissing(b1);" part to get b2 to ignore the coresponding point. But for some reason it does not want to graph b3 or b4 despite having the variables update correctly. It really just wont plot at all. Any and all advice is welcomed, thanks in advance!

6 件のコメント

Torsten
Torsten 2023 年 6 月 6 日
Do b3 and b4 have the same size ? Do they contain Inf or -Inf elements ?
the cyclist
the cyclist 2023 年 6 月 6 日
Can you upload a set of data for which the plots work as expected, and a set of data for which it does not?
William
William 2023 年 6 月 6 日
@Torsten They are both 12 values long and no Inf or -Inf as well as no NaN in the data set.
William
William 2023 年 6 月 6 日
@the cyclist I'm not too sure how to do that efficiently, but here is the gyst of it:
Works:
b1: 3.0438 4.8398 4.3395 6.4327 7.2144 5.7503 7.7609 7.4249 6.2456 5.0813 5.1636 3.3193
b2: 6.9866 9.83901 8.8018 7.7805 8.68471 3.7041 9.5070 7.9843 9.7922 6.7468 7.6182 8.4969
b3: 0.0218 0.0350 0.0304 0.0412 0.0468 0.0438 0.0710 0.0883 0.1125 0.0297 0.0448 0.0494
b4: 0.0394 0.0435 0.0457 0.0366 0.0426 0.0330 0.0337 0.0310 0.0333 0.0313 0.0329 0.0317\
Doesnt work:
b1: 8.4874 9.1870 10.7755 10.9003 11.570 16.4168 3.4914 4.6170 7.5933 3.89766
b2: 11.6589 11.8874 24.9780 14.9634 12.3281 28.6672 12.1673 13.0639 27.7843 10.5510 15.2769 32.3900
b3: 0.0232 0.0272 0.0316 0.0373 0.0407 0.0398 0.2932 0.0574 0.0830 0.0439 0.0422 0.0419
b4:0.0385 0.0389 0.0362 0.0371 0.0433 0.0388 0.0349 0.0412 0.0446 0.0333 0.0369 0.0403
so b1 and b2 should only have 11 values in this one because there is an NaN in b1 and we are removing that and the corresponding value in b2 if that makes sense.
the cyclist
the cyclist 2023 年 6 月 6 日
FYI, to upload a MAT file with the data, you can use the paper clip icon in the INSERT section of the toolbar.
William
William 2023 年 6 月 6 日
@the cyclist Ah, ok thank you!

サインインしてコメントする。

 採用された回答

Cris LaPierre
Cris LaPierre 2023 年 6 月 6 日

1 投票

But b1 does not contain any NaN values here, and is a 1x10 while b2 is a 1x12. Your code would work if b1 actually contained the 2 NaN values that appear to have been removed. See below.
% I've added 2 NaN values to b1
b1 = [8.4874 9.1870 10.7755 10.9003 11.570 16.4168 3.4914 4.6170 7.5933 3.89766 nan nan];
b2 = [11.6589 11.8874 24.9780 14.9634 12.3281 28.6672 12.1673 13.0639 27.7843 10.5510 15.2769 32.3900];
b3 = [0.0232 0.0272 0.0316 0.0373 0.0407 0.0398 0.2932 0.0574 0.0830 0.0439 0.0422 0.0419];
b4 = [0.0385 0.0389 0.0362 0.0371 0.0433 0.0388 0.0349 0.0412 0.0446 0.0333 0.0369 0.0403];
ind = ~ismissing(b1);
ind1 = ~ismissing(b3);
figure
subplot(1,2,1);
drawnow
hAxes = gca;
hold(hAxes,"on");
xlabel('CSI Amp');
ylabel('Keyhole Amp Low Res');
%plot(hAxes,b1(ind),b2(ind));
scatter(b1(ind),b2(ind),'filled')
[R,p] = corrcoef(b1,b2);
R = R(2);
p = p(2);
title(['R =' num2str(R) ', p =' num2str(p)]);
hold(hAxes,"off");
subplot(1,2,2);
drawnow
gAxes = gca;
hold(gAxes,"on");
xlabel('CSI R2M Amp');
ylabel('Keyhole R2M Amp Low Res');
%plot(gAxes,b3(ind1),b4(ind1),'o');
scatter(b3(ind1),b4(ind1),'filled')
[R,p] = corrcoef(b3,b4);
R = R(2);
p = p(2);
title(['R =' num2str(R) ', p =' num2str(p)]);
hold(gAxes,"off");

1 件のコメント

William
William 2023 年 6 月 6 日
Ok I see where I was going wrong. Thank you for explaining that to me! Hope you have a good rest of your day.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

製品

質問済み:

2023 年 6 月 6 日

コメント済み:

2023 年 6 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by