Simple Question: How to Plot a Function over an Interval (Details in Body)

Hello, it's been too long since I've used Matlab.
Could someone please help me with the following? I tried looking online but other solutions didn't help me for some reason. Thanks in advance!
t = 0:0.01:pi % Theta from 0 to pi
tm = sqrt(44*cos(t).^2 + 44*cos(t)*sin(t)+29*sin(t).^2)
plot(t, tm(t))

3 件のコメント

Michael Meyne
Michael Meyne 2023 年 9 月 12 日
I've gotten one step closer but now with error:
t = 0:0.01:pi % Theta from 0 to pi
%
tm = sqrt(44.*cos(t).^2 + 44*cos(t).*sin(t)+29.*sin(t).^2) % traction magnitude eqn derived on paper
plot(t, tm(t))
Array indices must be positive integers or logical values.
Error in HW2_1a_SMI_Michael_Meyne (line 16)
plot(t, tm(t))
Torsten
Torsten 2023 年 9 月 12 日
編集済み: Torsten 2023 年 9 月 12 日
t = 0:0.01:pi; % Theta from 0 to pi
%
tm = sqrt(44*cos(t).^2 + 44*cos(t).*sin(t)+29*sin(t).^2); % traction magnitude eqn derived on paper
plot(t, tm)
Michael Meyne
Michael Meyne 2023 年 9 月 12 日
Thank you Torsten!

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

回答 (1 件)

Sam Chak
Sam Chak 2023 年 9 月 12 日
Alternatively, you can also use fplot() to symbolically plot the function over the specified interval for t.
syms t
tm = @(t) sqrt(44*cos(t).^2 + 44*cos(t).*sin(t) + 29*sin(t).^2);
fplot(tm, [0 pi])
grid on
title('tm(t) from 0 to \pi')
xlabel('t');
ylabel('tm');

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

質問済み:

2023 年 9 月 12 日

回答済み:

2023 年 9 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by