How to Plot a Graph for a Range of Values

46 ビュー (過去 30 日間)
Tom
Tom 2018 年 11 月 15 日
コメント済み: Tom 2018 年 11 月 16 日
I am working on a problem in mechanics and have obtained an expression for the force on an object: the expression contains several constants and a parameter. In the code elsewhere I have stated that this parameter just has an arbitrary value of 1 after dimensionalisation, but I need to now allow it to vary from 0 to 1 and plot the expression as a function on a graph depending on the parameter, what would be the easiest way of doing this?
I know MATLAB has a plot(X,Y) function, but obviously this will not work immediately as I have already fixed the parameter essentially arbitrarily just to obtain a numerical value which I can compare with other expressions.

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 15 日
編集済み: madhan ravi 2018 年 11 月 15 日
how about this example: (if it doesn't work provide your code and datas)
syms x(t)
x(t)=t*exp(t-1)
fplot(x(t),[0 1]) % ranging from 0 to 1
  2 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 16 日
if my answer worked make sure to accept the answer
Tom
Tom 2018 年 11 月 16 日
It didn't work, I get a function which doesn't look right.

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

その他の回答 (1 件)

Tom
Tom 2018 年 11 月 15 日
I'm not sure if that will work, I will give an example of the code to see if that helps. Basically, there is a parameter Kn which I set to 1 in the course of finding the solution which gives the force on an object. I have a function which features Kn which is evaluated numerically at various grid points.
function [V]=StokesletEval(rij,normal)
Kn=1;
J=1/(8*pi*Kn)*(eye(3)/norm(rij)+(rij'*rij)/((norm(rij))^3));
K=(-1/(4*pi))*(rij'*normal*(eye(3)/norm(rij)^3-3*(rij'*rij)/norm(rij)^5)*(eye(3)-normal'*normal));
V=(J+sqrt(pi/2)*K);
end
Evaluating the function at the grid and solving the system which results you get the total force (or drag) called dragFZ. I then divide the result by -6*pi*VZ*Kn, another equation which depends on Kn. Although I have assumed Kn=1, I somehow need to take that ratio and plot the result against Kn, as Kn varies from 0 to 1. I have tried the following (where I called Kn t):
syms x(t)
x(t)=dragFZ/(-6*pi*VZ*t);
fplot(x(t),[0 1])
but the graph does come out as expected.

カテゴリ

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

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by