How do I plot two graphs on one figure?

3 ビュー (過去 30 日間)
Dhaval Gajera
Dhaval Gajera 2018 年 8 月 18 日
コメント済み: Dhaval Gajera 2018 年 8 月 20 日
I have written this function. It calculates beam deflection for the range provided. Now I want to differentiate the equation and find value of the equation at the same range and want to plot the graph on same graph.
clear all clc clf
%This program calculates deflaction of beam subject to tapering load 'w'.
syms x
w = 122.35 %kN/cm; L = 150 %cm; E = 27000 %kN/cm^2; I = 35000 %cm^4; x = linspace(0,150,1000);
y = w*((-x.^5)+(2*L.^2*x.^3)-(L.^4*x))/(120*E*I*L)
plot(x,y)

回答 (1 件)

Henry Giddens
Henry Giddens 2018 年 8 月 18 日
編集済み: Henry Giddens 2018 年 8 月 18 日
Something like:
dy = diff(y);
dx = diff(x);
plot(x,y);
hold on;
plot(x(1:end-1),dy./dx)
The gradient using diff is calculated between points X(n) and X(n+1), so dX has a size of one element less than x. Therefore you may need to adjust according to what you want to plot
x2 = x(1:end-1) + (x(2)-x(1))/2; %Does this work?
plot(x2,dy./dx)
  1 件のコメント
Dhaval Gajera
Dhaval Gajera 2018 年 8 月 20 日
Hi Henry,
Thanks for your answer. However, my question is a bit different. This is what I am trying to solve:
The deflection y of a beam subject to a tapering load w, may be computed as,
{{There is an equation that I have written in code}}
Compute and plot the beam deflection, y, along the beam length, x, as well as the rate of change of deflection (dy/dx).

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by