# I want to plot a graph like this in Matlab. It would be a great help if someone can help me with the same by providing the code.

1 ビュー (過去 30 日間)
Shawn Anto Thekkiniath 2020 年 8 月 10 日
コメント済み: Antonio Aguirre 2020 年 8 月 14 日
The function is
y(x,t) = ((c1*x )+ (c2*x^2)) * (0.08*x) * (sin((10.2*x)+(2*pi*i/8))) * (sin((10.2*x)-(2*pi*i/8)))
c1 = 0.08
c2 = 0
i = 1 to 7

#### 1 件のコメント

KSSV 2020 年 8 月 10 日
What have you attempted?

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

### 採用された回答

Antonio Aguirre 2020 年 8 月 13 日
Hi,
So I tried the following below. Minus the LaTeX formatting, I think it's exactly what you need. Also, the function that you gave does not produce the necessary values to produce the example plot that you showed in your post. Any way, check out what I've done and maybe I've got a typo in the function. Don't forget to give me a "Thumbs Up" vote if this was helpful, thanks!
%% Start clean and clear
clc,clear,close all
%% Define constants
c1 = 0.08;
c2 = 0;
c3 = 10.2;
%% Define the function to plot, anonymous function
fcn = @(i,x,c1,c2,c3) ( (c1.*x) + (c2.*x.^2) ) .* ( c1.*x ) .* ( sin( (c3.*x) + (2*pi*i/8) ) ) .* ( sin( (c3.*x) - (2*pi*i/8) ) );
%% Define the domain of the function
x = 0:0.001:0.6;
%% Initialize the figure space
figure
hold on
%% Iterate to plot the function
for i = 1:7
% Return the function response
y = fcn( i, x, c1, c2, c3 );
% Plot the function response
plot( x, y, 'b' )
% Add a data label to the line
text( x(end)+0.005, y(end), sprintf('i = %d', i) )
end
%% Configure the plot aesthetics
grid on
xlim( [0,0.7] )
xlabel( 'x (m)' )
ylabel( 'y (m)' )
title( 'c1 = 0.08 c2 = 0' )

#### 2 件のコメント

Shawn Anto Thekkiniath 2020 年 8 月 14 日
thanks:)
Antonio Aguirre 2020 年 8 月 14 日
Any time!

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

### その他の回答 (1 件)

Sudheer Bhimireddy 2020 年 8 月 10 日
Neglecting i=0, you will have 7 lines governed by that equation.
Have you tried it by using a simple loop for i = 1:7 ?
x = 0:0.01:1;
for i = 1:7
end
Show us what you have tried and where you are facing a problem.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by