code error for Two Point Boundary Value Problem

11 vues (au cours des 30 derniers jours)
leeee
leeee le 20 Nov 2019
Commenté : leeee le 21 Nov 2019
Hello, I have no idea what is wrong...any ideas would help, thanks!
function [A,b,x]=task14(n)
%n=149
t1=1;
tn=10;
y1=-4;
yn=-1;
h=(tn-t1)/n;
t=t1:h:tn;
A=zeros(n+1,3);
b=zeros(n+1,1);
for i=2:1:n
t2=t(i);
y(i-1)=(t2+4)/(h^2)-(1-t2^2)/(2*h);
y(i)=-2*(t2+4)/(h^2)+3*cos(2*t2);
y(i+1)=(t2+4)/(h^2)+( 1-t2^2 )/(2*h);
A(:,1)=[y(i-1)];
A(:,2)=[y(i)];
A(:,3)=[y(i+1)];
b(i,1)=2*sin(2*t1)-cos(3*t1)-3*cos(2*t1);
end
x=A\b

Réponses (1)

KALYAN ACHARJYA
KALYAN ACHARJYA le 20 Nov 2019
I did not find any coding error in your code, just save the task14 function file in the same directory. You can call the saved task14.m file from the main matlab script or command window.
6789.png
  1 commentaire
leeee
leeee le 21 Nov 2019
thanks but i should have 150 results of x

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by