fixed points in the plots
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi,
I have a program that includes a graph of functions in 3D
I need to fix points on the drawing (show the location of the points on the drawing),
I used
hold on ;
plot (A(1),B(2.1),G(3.021),'r*')
plot (A(0.0001),B(3),G(3.21),'r*')
plot (A(3.654),B(3.1),G(2.15),'r*')
But an error appeared to me...
Error in POINTS (line 45)
plot (A(1),B(2.1),G(3.021),'r*')
if any Prof. can help me ...thanks alot
採用された回答
Walter Roberson
2021 年 4 月 11 日
syms A B G
A, B, and G are created as scalar symbols
f = matlabFunction(sum1m2, 'vars', [A, B, G]);
g = matlabFunction(sum3m4, 'vars', [A, B, G]);
h = matlabFunction(sum5m6, 'vars', [A, B, G]);
f, g, and h are created as numeric functions of three inputs.
plot (A(1),B(2.1),G(3.021),'r*')
plot (A(0.0001),B(3),G(3.21),'r*')
plot (A(3.654),B(3.1),G(2.15),'r*')
You try to index scalar A at 1, which works, giving you back the scalar symbol A .
You try to index scalar B at 2.1, which fails, because you cannot index at non-integers... and if you could do that, you would be indexing past the end of the scalar.
You try to index scalar G at 3.021, which fails, non integer, past the end of the scalar. Is it possible that function g was intended? But function g needs three parameters, not one.
I suspect what you want is
plot ((1),(2.1),(3.021),'r*')
plot ((0.0001),(3),(3.21),'r*')
plot ((3.654),(3.1),(2.15),'r*')
10 件のコメント
hasan s
2021 年 4 月 12 日
Thanks Prof. Walter for the valuable answer... yes I want these points..I write it but also not appear in the graph
hasan s
2021 年 4 月 17 日
I write the points as integer, but also not appear in the graph..
is imposible fixed points in graph in matlab???
Walter Roberson
2021 年 4 月 17 日
It works for me. If I take your code and remove the
plot (A(1),B(2.1),G(3.021),'r*')
plot (A(0.0001),B(3),G(3.21),'r*')
plot (A(3.654),B(3.1),G(2.15),'r*')
which we already know to be wrong, and if we put in
plot3(1,2,3,'r*')
then you can see a red star in the graph.
You have "hold on" in effect, and your xlim, ylim, and zlim are all [0 4], so if you were to try to draw at points outside that range, then they would not be in view. For example if you wanted to plot at 4.1 3.1 2.1 then it would be off the screen. If that happens you can use
xlim auto; ylim auto; zlim auto
realy appear in your matlab ... why not appear in my matlab ???
please where you put
plot ((1),(2.1),(3.021),'r*')
plot ((0.0001),(3),(3.21),'r*')
plot ((3.654),(3.1),(2.15),'r*')
I put it in the end of program , and I take the same file in the interval [0,4].please , if you can ..attach the file that appear the 3 points
I try
plot3(1,2,3,'r*')
and appear * without graph of functions
Walter Roberson
2021 年 4 月 17 日
NumPoints = 50;
tic
digits(16);
syms A B G
N = 100;
Q1 = rand(10,N);
Q = vpa(reshape(Q1,1,[]));
sum1=0;sum2=0;sum3=0;sum4=0;sum5=0;sum6=0;
for j=1:1000
sum1=sum1+1/(A+(G*B*((Q(j))^(G-1))));
sum2=sum2+(Q(j));
sum3=sum3+(G*((Q(j))^(G-1)))/(A+(G*B*((Q(j))^(G-1))));
sum4=sum4+(Q(j))^(G);
sum5=sum5+(((G*log(Q(j)))*((Q(j))^(G-1)))+((Q(j))^(G-1)))/(A+(B*G*((Q(j))^(G-1))));
sum6=sum6+((Q(j))^(G))*log(Q(j));
end
sum1m2 = vpa(sum1 - sum2);
sum3m4 = vpa(sum3 - sum4);
sum5m6 = vpa(B*sum5-B*sum6);
f = matlabFunction(sum1m2, 'vars', [A, B, G]);
g = matlabFunction(sum3m4, 'vars', [A, B, G]);
h = matlabFunction(sum5m6, 'vars', [A, B, G]);
[Ag, Bg, Gg] = meshgrid(linspace(0, 4,NumPoints));
Fgrid = f(Ag,Bg,Gg);
Ggrid = g(Ag,Bg,Gg);
Hgrid = h(Ag,Bg,Gg);
grids = {Fgrid, Ggrid, Hgrid};
gridnames = {'f', 'g', 'h'};
ngrid = length(grids);
cmap = parula(ngrid);
view(3);
patches = gobjects(1,ngrid);
surfaces = cell(ngrid, 1);
for K = 1 : ngrid
surfaces{K} = isosurface(Ag, Bg, Gg, grids{K}, 0);
patches(K) = patch(surfaces{K}, 'facecolor', cmap(K,:), 'edgecolor','none','FaceAlpha', 0.5, 'displayname', gridnames{K});
end
xlabel('A');
ylabel('B');
zlabel('G');
legend show
hold on ;
plot3((1),(2.1),(3.021),'r*')
plot3((0.0001),(3),(3.21),'r*')
plot3((3.654),(3.1),(2.15),'r*')
hold off
toc
hasan s
2021 年 4 月 17 日
Now the points appear ...
Thank you very very much prof. Walter
please ...Why did the point name not appear with * , as
A 1
B 2.1
G 3.021
Walter Roberson
2021 年 4 月 17 日
You did not ask for that.
points = [
1, 2.1, 3.021;
0.0001, 3, 3.21;
3.654, 3.1, 2.15;
]
scatter3(points(:,1), points(:,2), points(:,3), 'r*');
for K = 1 : size(points,1)
text(points(K,1), points(K,2), points(K,3), sprintf('A=%g B=%g G=%g', points(K,:)));
end
hasan s
2021 年 4 月 17 日
Sorry, I thought it appears without other commands...
thank you very very much Prof. Walter
Walter Roberson
2021 年 4 月 17 日
There are also datatips(), but datatips() automatically move to the closest data point, which I did not think you would want to do.
hasan s
2021 年 4 月 18 日
Thanks prof. Walter for this valuable information ... Yes, right now, I just need to hold the points
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Contour Plots についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
