MATLAB Plot points joining

Hi,
When I run the following code:
A=tau_invp;
B=T_delayp;
C=K_olp;
figure
grid
hold on;
for n=1:length(zeta_dom_r)
if abs(zeta_dom_r(n)-0.000)>0.0001
A(n)=0;
B(n)=0;
C(n)=0;
end
end
D=A./B;
plot(C, D, '.')
xlabel('K_{ol}');
ylabel('\alpha \propto (\tau/T)');
xlim([0 3]);
ylim([0 2]);
I get the image with six dot points. But when I put '.-' instead of '.', nothing changes on the graph. I still see simple dots. What could be a possible reason for that? I want to see the dots connected.

回答 (2 件)

Star Strider
Star Strider 2015 年 9 月 17 日

0 投票

I can’t run your code because I don’t have your data.
What is the result if you do:
plot(C, D, '-r')
or simply:
plot(C, D)

9 件のコメント

Waqas Syed
Waqas Syed 2015 年 9 月 17 日
Hi,
In both the cases, I get empty figures.
Star Strider
Star Strider 2015 年 9 月 17 日
I can’t run your code because I don’t have your data.
What are ‘C’ and ‘D’?
Waqas Syed
Waqas Syed 2015 年 9 月 17 日
I have attached the data for your reference. You can try it out aswell. i will be grateful.
Waqas Syed
Waqas Syed 2015 年 9 月 17 日
Hey Star Strider,
Are you able to access the data that I have provided? Simply import it and run the code and it should be fine.
Star Strider
Star Strider 2015 年 9 月 17 日
I don’t have ‘zeta_dom_r’.
Waqas Syed
Waqas Syed 2015 年 9 月 18 日
Hey, I am sorry I missed out on zeta_dom_r.
Please find attached the file with all the four data elements. Don't use the previous one. I changed it slightly. Anxiously waiting for your response.
Star Strider
Star Strider 2015 年 9 月 18 日
No file yet.
Waqas Syed
Waqas Syed 2015 年 9 月 18 日
Don't know what happened there. Here it is again.
Star Strider
Star Strider 2015 年 9 月 18 日
I experimented with it, and when I minimally changed your code to move the plot to be after the loop instead of including the loop:
load('Newdata_N60.mat');
A=tau_invp;
B=T_delayp;
C=K_olp;
for n=1:length(zeta_dom)
if abs(zeta_dom(n)-0.000)>0.0001
A(n)=0;
B(n)=0;
C(n)=0;
end
end
D = A./B;
Dv = find(~isnan(D));
Dr = [min(Dv) max(Dv)];
figure(1)
plot(C(Dv), D(Dv), 'bp')
xlabel('K_{ol}');
ylabel('\alpha \propto (\tau/T)');
xlim([0 3]);
ylim([0 2]);
grid
I discovered (with ‘Dv’) that you have only one non-NaN point in D. (I plotted it as a star so I could see it. You mentioned that you got six plotted points, so we must not be using the same data.) If you have more than one valid data point, change the plot call to replace 'bp' with 'b.-' to connect them.
Note that NaN values don’t plot, and interrupt the connections between data that otherwise do plot, so it is necessary to eliminate the NaN values before plotting them (as I did here) in order to connect them.

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

Tim Jackman
Tim Jackman 2015 年 9 月 17 日

0 投票

Try manually setting the LineStyle property manually:
>> lHandle = get(gca,'Children')
>> set(lHandle,'LineStyle','-')

1 件のコメント

Waqas Syed
Waqas Syed 2015 年 9 月 17 日
Added these two lines to my code. Figure is returned as empty.

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

カテゴリ

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

タグ

質問済み:

2015 年 9 月 17 日

コメント済み:

2015 年 9 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by