Trying to find the function of x for 0<=x<=2L

1 回表示 (過去 30 日間)
Skye Cameron
Skye Cameron 2020 年 2 月 17 日
コメント済み: John D'Errico 2020 年 2 月 17 日
clc; clear; close all; format short g;
%knowns
gamma = 1.4;
R = 8.31;
m = 4.0;
P0 = 10;
T0 = 300;
r0 = 0.01;
L = 0.05;
%function
x = [0:2*L];
func = @(x) r0((2*(x)/L)+ exp(-2*(x)/L));
y = func(x);
%graph
plot (x,y)
  3 件のコメント
fadams18
fadams18 2020 年 2 月 17 日
can you post a snapshot of your function. what are all those values P0 and T0 for. i dont see where you have used them in the function
John D'Errico
John D'Errico 2020 年 2 月 17 日
Rathr thn trying to use the colon operator to create x, as
x = [0:2*L];
you should learn to use linspace.

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

採用された回答

Stephen23
Stephen23 2020 年 2 月 17 日
編集済み: Stephen23 2020 年 2 月 17 日
Two changes:
  1. you defined x to contain exactly one value, which is not very useful for plotting.
  2. you were missing some multiplications inside the function definition.
Fixed here:
>> func = @(x) r0*(2*x./L + exp(-2*x./L));
>> X = 0:0.01:2*L;
>> Y = func(X);
>> plot(X,Y)

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by