How to plot a function in 2d with function from 3d

3 ビュー (過去 30 日間)
Jacob Andréasson
Jacob Andréasson 2019 年 11 月 9 日
コメント済み: Jacob Andréasson 2019 年 11 月 10 日
Hey!
I am finished with a and b but i need much help with c. Down below is the information from the exercise.
Down below is my script for a and b but i do not know if the script that I have for C i correct.
%% Exercise 2.a
clear
clf
clc
k=1
L=6
x=linspace(0,L);
fplot(@(x) (((2.*k)./L).*x), [0,(L/2)])
hold on
fplot(@(x) (((2.*k)./L).*(L-x)), [(L/2),L])
%% Exercise 2.b
clear
clf
clc
k=1;
L=6;
T=10;
x=linspace(0,L,100); t=linspace(0,T,100);
n=1:100;
for i=1 : length(x)
for j=1 : length(t)
u(i,j)=(8/(pi^2)).*sum((1./(n.^2)).*sin(n.*pi/2).*cos(n.*pi.*t(j)/6).*sin(n.*pi.*x(i)/6));
end
end
surf(t,x,u)
xlabel('t'); ylabel('x'); zlabel('u')
title('Exercise 2.b');
%% Exercise 2.c
clear
clf
clc
k=1;
L=6;
T=10;
x=linspace(0,L,100); t=linspace(0,T,100);
n=1:100;
for i=1 : length(x)
for j=1 : length(t)
u(i,j)=(8/(pi^2)).*sum((1./(n.^2)).*sin(n.*pi/2).*cos(n.*pi.*t(j)/6).*sin(n.*pi.*x(i)/6));
end
end
plot(x,u)
xlabel('x'); ylabel('u');
title('Exercise 2.c');
  2 件のコメント
darova
darova 2019 年 11 月 9 日
c)
for i = 1:size(u,1)
plot(t,u(i,:))
pause(0.05)
end
Jacob Andréasson
Jacob Andréasson 2019 年 11 月 10 日
thank you so much!!!!

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by