Filter löschen
Filter löschen

How to plot vector valued function with single input.

3 Ansichten (letzte 30 Tage)
Niklas Kurz
Niklas Kurz am 22 Dez. 2020
Kommentiert: Walter Roberson am 23 Dez. 2020
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)] ?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Dez. 2020
syms phi real
f(phi) = [cos(phi); sin(phi)];
fplot(f)
  3 Kommentare
Niklas Kurz
Niklas Kurz am 23 Dez. 2020
But can't you plot it like f(phi,0) = [cos(phi); sin(phi)]. How to achieve this?
Walter Roberson
Walter Roberson am 23 Dez. 2020
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)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by