can you write a vector function?

조회 수: 32 (최근 30일)
Thomas Starai
Thomas Starai 2019년 6월 23일
댓글: Star Strider 2020년 1월 6일
I am looking to express a parametrized vector function and draw the surface..
  댓글 수: 2
Adam Danz
Adam Danz 2019년 6월 23일
How can we help you with that? Where are you stuck?
Thomas Starai
Thomas Starai 2019년 6월 23일
What is the syntax for something like:
x(u,v) = ( 2-v*sin(u/2)*sin(u), 2-v*sin(u/2)*cos(u), v*cos(u/2) )
?

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

채택된 답변

Star Strider
Star Strider 2019년 6월 24일
You pretty much wrote it yourself:
x = @(u,v) [2-v.*sin(u/2).*sin(u); 2-v.*sin(u/2).*cos(u); v.*cos(u/2)];
See the documentation sections on Anonymous Functions (link) and Vectorization (link) for an extended discussion of both. The documentation for the ndgrid (link) function will also be helpful.
  댓글 수: 4
Thomas Starai
Thomas Starai 2019년 6월 24일
Symbolic math is intriging.....efficiency is not an issue.
After looking at anonymous functions, I fail to see why you couldn't just define a function without the @ operator. Can you provided some insigh as to why this is necessary?
Star Strider
Star Strider 2019년 6월 24일
The @ operator denotes a function handle, and is necessary if you want to define it as an anonymous function. You could define it as a function file, however that is usually reserved for more complicated functions. See Function Basics for details.
You don’t have to define it as a function if you don’t want to — it will simply execute as a statement instead, although you could not then use it as a function later in your code — however in your original Question you specified that it is a function. See What Is a Function Handle? for an extended discussion.

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

추가 답변 (1개)

Ali Zain
Ali Zain 2020년 1월 6일
y= function(t)=[0.2582;
-0.3631 cos(0.21910*(t);
0.3572 cos(0.4158)(t);
0.3473*cos(0.6180t);
0.3336*cos(0.8135t);
0.3162*cos(t);
0.2954*cos(1.1756t);
0.2714*cos(1.3383t);
0.2443*cos(1.4863t);
0.2146*cos(1.6180t);
0.1826*cos(1.7321t);
0.1485*cos(1.8271t);
0.1128*cos(1.902t);
-0.0759*cos(1.9563t);
0.0382*cos(1.9890t)]
why it is giving error...
  댓글 수: 1
Star Strider
Star Strider 2020년 1월 6일
Except for the second line, there is no multiplication operator.

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

카테고리

Help CenterFile Exchange에서 MuPAD에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by