fixed points in the plots
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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일
0 개 추천
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???
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
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
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
