How to plot vector valued function with single input.

4 ビュー (過去 30 日間)
Niklas Kurz
Niklas Kurz 2020 年 12 月 22 日
コメント済み: Walter Roberson 2020 年 12 月 23 日
I wonder if this is even possible and the question itself is redundant. Normaly a vector valued function is plotted with 2 inputs:
[x,y] = meshgrid(-1:0.1:1);
fx = x.^2;
fy = 3.*y;
quiver(x,y,fx,fy)
in order that each (x,y) input in the coordinate plane is adressed to an output (I suppose). Probably that's rather a question for Mathstack, but while I'm at it: is it possible to plot a function that goes like f(phi) = [cos(phi); sin(phi)] ?

採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 22 日
syms phi real
f(phi) = [cos(phi); sin(phi)];
fplot(f)
  3 件のコメント
Niklas Kurz
Niklas Kurz 2020 年 12 月 23 日
But can't you plot it like f(phi,0) = [cos(phi); sin(phi)]. How to achieve this?
Walter Roberson
Walter Roberson 2020 年 12 月 23 日
You cannot do that.
If f in that syntax were a numeric array or a cell array, then the 0 would be an invalid index.
If f in that syntax is a symbolic function name that you are defining, then the arguments to f() on the left side of a symbolic function definition must each be scalar symbolic variable names or row vectors of symbolic variable names (unless there is only a single parameter, in which case it is permitted to be a column vector of symbolic variable names.) 0 is not a valid symbolic variable name, so f(phi,0) cannot be defined.
It is not possible to define a symbolic function in parts. For example it is not possible to define
f(0,0) = -1
f(0,phi) = sin(phi)
f(theta,0) = theta^2
Each symbolic function can only be defined in a single statement -- though the statement can use piecewise():
f(theta,phi) = piecewise(theta==0 & phi == 0, -1, theta == 0, sin(phi), phi == 0, theta^2, etc)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by