coordinate data in the text command

조회 수: 1 (최근 30일)
hans
hans 2021년 12월 16일
댓글: hans 2021년 12월 16일
Is it possible to somehow put both, x- and y-coordinate, with a single variable of two fields into the location fields of the text-command?
instead of :
loc = [0.5,0.5];
figure; text(loc(1),loc(2),'a')
something like
Is it possible to somehow put both, x- and y-coordinate, into the location fields of the text-command?
instead of :
loc = [0.5;0.5];
figure; text(loc,'a')

채택된 답변

Rik
Rik 2021년 12월 16일
You have two options that I'm aware of:
  1. Write a wrapper function that will split your vector as approriate.
  2. Use a comma separated list: loc=[0.5;0.5];loc=num2cell(loc);text(loc{:},'a')
  댓글 수: 13
hans
hans 2021년 12월 16일
편집: hans 2021년 12월 16일
"Your usage of the terms "writing and reading" is not clear to me. "
  • I used writing for may be a better word might be "assigning a value to a variable" e.g. a=1
  • I used reading for replacing the "value of a variable" by the "variable"
"No, a comma separated list is a list of variables separated by commas."
That is obviously correct. But I try to talk about the field of application of this list.
So may be it is more suitable to modify my statement by ""The "comma separated" is a special communication form for assigning values to arrays and using these arrays to replace a comma separated list of arguments, which was expected in a command"
My point is, that the application of a comma separated list is only in the communication i.e. assigning and use of arrays
hans
hans 2021년 12월 16일
May be to tell it shorter:
It seems to me comma separated lists have their dominating area of application assigning values to arrays and to fill argument lists of commands/functions

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 12월 16일
text('String', 'a', 'Position', loc)
  댓글 수: 1
hans
hans 2021년 12월 16일
편집: hans 2021년 12월 16일
Thank You for Your contribution.
I'm still confused, why the text command accept this syntax of loc after the 'Position' switch, but not as the first entry of the text command
Why does the first position require a cell variable
the second requires a vector
loc = {0.5;0.5}
figure
text(loc{:},'a')
clear
loc = [0.5 0.5]
figure
text('Position', loc, 'String','a');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by