How to plot vector valued function with single input.

조회 수: 5 (최근 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 CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by