Subscript indices must either be real positive integers or logicals.
Show older comments
I have a problem with this code and when i run it, matlab said : Subscript indices must either be real positive integers or logicals. please help me for this (i attached all functions that need for run this program)
clc; clear all; close all;
%2D WAVE EQUATION utt = c^2(uxx+uyy)
%with initial condition u(x,y,0) = sin(p*pi*x)*sin(q*pi*y), 0<x<1 0<y<1
% and boundary conditions u(0,y,t) = u(1,y,t)= u(x,0,t)= u(x,1,t) = 0 t>0
ri = 1;
deltar = 0.01;
deltaz = 0.01;
C = 1;
dx = 0.01;
dy = dx;
sigma = 1/sqrt(2); gamma = 1/sqrt(2); %Courant-Friedrich Stability Condition
dt = sigma*(dx/C);
t = 0:dt:1; x = 0:dx:1; y = 0:dy:1;
u = zeros(length(x),length(y),length(t));
p = 2; q = 1;
u(:,:,1) = transpose(sin(p.*pi.*x))*sin(q.*pi.*y); %u(x,y,0) = sin(p*pi*x)*sin(q*pi*y)
%u(x,y,dt)
for i=2:length(x)-1
for j=2:length(y)-1
z = 1:0.1:2;
for zindex=1:11
n = [0.1,1,10];
for nindex=1:3
u(i, j, 2, z(zindex), n(nindex))= G(z(zindex), n(nindex))/ro(z(zindex), n(nindex))^2*dt^2*((1/deltar^2)*(u(i+1,j,1)-2*u(i,j,1)+u(i-1,j,1))...
+(1/(ri*2*deltar))*(u(i+1,j,1)-u(i-1,j,1))+(1/deltaz^2)*(u(i,j+1,1)-2*u(i,j,1)+u(i,j-1,1))-(1/ri^2)*(u(i,j,1))) + 2*u(i,j,1) - u(i,j,1);
end
end
end
end
1 Comment
KSSV
on 7 Dec 2017
It is time now to learn about debugging the code. Explore it.
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!