### Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

## How do I plot a certain interval?

may95

### may95 (view profile)

さんによって質問されました 2019 年 3 月 23 日

### Star Strider (view profile)

さんによって コメントされました 2019 年 3 月 23 日
Star Strider

### Star Strider (view profile)

さんの 回答が採用されました
Hi guys,
So I'm trying to plot an interval between [8 12], but I don't know where to start, as I'm not using x-values in my function.
So this is the idea:
And this is my script:
for N = 8;
Mc = [-2:0.01:15]*N;
Pi_c = 1+(2*N-1)*(3-2*Mc/N).*(Mc/N).^2;
end
plot(Mc,Pi_c,'k')
axis([-4 13 1 17])
xlabel('m_c')
ylabel('pressure ratio')
title('Simplified compressor characteristic')
Any help would be greatly appreciated!

#### 0 件のコメント

サインイン to comment.

## 2 件の回答

### Star Strider (view profile)

2019 年 3 月 23 日
採用された回答

This will overplot the region (8,12) with a red dashed line:
for N = 8;
Mc = [-2:0.01:15]*N;
Pi_c = 1+(2*N-1)*(3-2*Mc/N).*(Mc/N).^2;
end
plot(Mc,Pi_c,'k')
hold on
McIdx = (Mc >= 8) & (Mc <= 12); % Select Elements (Logical Vector)
plot(Mc(McIdx), Pi_c(McIdx), '--r') % Plot Range
hold off
axis([-4 13 1 17])
xlabel('m_c')
ylabel('pressure ratio')
title('Simplified compressor characteristic')
Experiment to get the result you want.

may95

### may95 (view profile)

2019 年 3 月 23 日
OMG you are amazing! Thank you so much!
Star Strider

### Star Strider (view profile)

2019 年 3 月 23 日
As always, my pleasure!

サインイン to comment.

### John D'Errico (view profile)

2019 年 3 月 23 日

I'm confused. That you are not using x-values does not seem relevant. You plotted Mc on the horizontal axis.
Next, the line:
for N = 8
Does not create a loop. Well, it does, but the loop has length only one step, at N=8. All it does is assign the value of 8 to N.
Next, you want Mc to lie between 8 and 12.
N = 8;
Mc = linspace(8,12,100);
Pi_c = 1+(2*N-1)*(3-2*Mc/N).*(Mc/N).^2;
plot(Mc,Pi_c)
Which is only the region you seem to be interested in. We can even add some white space on the axes, to show you that indeed, only the part of interest was created.
axis([-4,13,0,17])

may95

### may95 (view profile)

2019 年 3 月 23 日
Hi John, thank you very much for the explanation!

サインイン to comment.

Translated by