I think my program is complete What happen to this line? u(i)=sin(pi

MATLAB.In summary, the conversation is about a complete MATLAB program and the question of what happened to the line "u(i)=sin(pi*x(i));". The program includes the equations and parameters used, as well as the computation of u values at different times. The speaker is seeking help in locating any potential errors in the program.
  • #1
iwan89
27
0

Homework Statement


I think my program is complete.. What happen to this line? u(i)=sin(pi*x(i)); ??


Homework Equations



n=10;
c1=0;
c2=0;
k= 0.0025;
L=1;
h=0.1;
alpha=1;
T=0.025;
n=L/h;m=T/k;
lambda =alpha*k/(h^2);
z=0:h:L;
disp('______________________________________________')
fprintf(' t x = ')
fprintf('%4.2f ',z)
fprintf('\n')
disp('____________________________________________ _')
fprintf('% 5.4f ',0)
% Compute the values of u at t=0
for i=1:n+1
u(i)=sin(pi*x(i));
fprintf('%10.6f ',u(i))
end
fprintf('\n')
% Compute the values of u t=jk, k=1,2,...,m
for j=1:m
t=j*k;
fprintf('% 5.4f ',t)
for i=1:n+1
if (i==1)
y(i)=c1;
elseif (i==n+1)
y(i)=c2;
else
y(i)=(1-2*lambda)*u(i)+lambda*(u(i+1)+u(i-1));
end;
fprintf('%10.6f ',y(i))
end;
fprintf('\n')
u=y;
end;

The Attempt at a Solution


There might be error somewhere. Please help me to locate it :(
 
Physics news on Phys.org
  • #2
this is a MATLAB program
 

FAQ: I think my program is complete What happen to this line? u(i)=sin(pi

1. What does the line "u(i)=sin(pi" mean in my program?

The line "u(i)=sin(pi" is a mathematical expression that calculates the sine of the value pi. It is likely used in a program to perform a mathematical operation or to generate a specific output.

2. Why am I getting an error for this line "u(i)=sin(pi" in my program?

The error could be due to a variety of reasons, such as incorrect syntax, missing variables, or an unsupported operation. It is important to carefully review the code and debug any errors to identify the specific issue.

3. Can I replace "u(i)=sin(pi" with a different mathematical expression in my program?

Yes, you can replace "u(i)=sin(pi" with a different mathematical expression as long as it is supported by the programming language and serves the intended purpose in your program.

4. How can I modify "u(i)=sin(pi" to work with different values in my program?

You can modify "u(i)=sin(pi" by changing the value of the variable or using a different mathematical expression to achieve the desired result. It is important to understand the purpose of this line in your program and make appropriate modifications.

5. Is "u(i)=sin(pi" a necessary line in my program or can I remove it?

It depends on the specific program and its purpose. If "u(i)=sin(pi" is used to perform a critical calculation or generate a crucial output, it may be necessary to keep it in the program. However, if it is not essential and can be replaced or removed without affecting the functionality, it can be modified or deleted.

Similar threads

Replies
10
Views
2K
Replies
1
Views
3K
Replies
5
Views
3K
Replies
1
Views
2K
Replies
2
Views
4K
Replies
5
Views
2K
Replies
7
Views
2K
Back
Top