Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write Matlab code to implement the Crank-Nicolson method to solve the one-dim

ID: 3184128 • Letter: 1

Question

1) Write Matlab code to implement the Crank-Nicolson method to solve the one-dimensional heat equation Cusz combined with the boundary conditions u(t, 0) = a(t) and initial condition u(0,)g) Here c is a positive constant. Note that the boundary condition functions and are not constant: they are functions of t. Employ the proper tridiagonal solving strategy. Use Matlab's contourf and colorbar commands to illustrate your results. 2) Repeat exercise 1) above, but thie time use the boundary conditions u (4,0) = a(t) Use the "fictitious node" technique for the Neumann boundary condition.

Explanation / Answer

.file 1 "" .section .mdebug.abi32 .previous .nan legacy .module fp=32 .module nooddspreg .abicalls .rdata .align 2 $LC0: .ascii "Enter an alphabet: " .align 2 $LC1: .ascii "%c" .align 2 $LC2: .ascii "%c is a vowel." .align 2 $LC3: .ascii "%c is a consonant." .text .align 2 .globl main .set nomips16 .set nomicromips .ent main .type main, @function main: .frame $fp,48,$31 # vars= 16, regs= 2/0, args= 16, gp= 8 .mask 0xc0000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-48 sw $31,44($sp) sw $fp,40($sp) move $fp,$sp .cprestore 16 movz $31,$31,$0 lw $2,%got($LC0)($28) nop addiu $4,$2,%lo($LC0) lw $2,%call16(printf)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,printf 1: jalr $25 nop lw $28,16($fp) addiu $2,$fp,32 move $5,$2 lw $2,%got($LC1)($28) nop addiu $4,$2,%lo($LC1) lw $2,%call16(__isoc99_scanf)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,__isoc99_scanf 1: jalr $25 nop lw $28,16($fp) lb $3,32($fp) li $2,97 # 0x61 beq $3,$2,$L2 nop lb $3,32($fp) li $2,101 # 0x65 beq $3,$2,$L2 nop lb $3,32($fp) li $2,105 # 0x69 beq $3,$2,$L2 nop lb $3,32($fp) li $2,111 # 0x6f beq $3,$2,$L2 nop lb $3,32($fp) li $2,117 # 0x75 bne $3,$2,$L3 nop $L2: li $2,1 # 0x1 b $L4 nop $L3: move $2,$0 $L4: sw $2,24($fp) lb $3,32($fp) li $2,65 # 0x41 beq $3,$2,$L5 nop lb $3,32($fp) li $2,69 # 0x45 beq $3,$2,$L5 nop lb $3,32($fp) li $2,73 # 0x49 beq $3,$2,$L5 nop lb $3,32($fp) li $2,79 # 0x4f beq $3,$2,$L5 nop lb $3,32($fp) li $2,85 # 0x55 bne $3,$2,$L6 nop $L5: li $2,1 # 0x1 b $L7 nop $L6: move $2,$0 $L7: sw $2,28($fp) lw $2,24($fp) nop bne $2,$0,$L8 nop lw $2,28($fp) nop beq $2,$0,$L9 nop $L8: lb $2,32($fp) nop move $5,$2 lw $2,%got($LC2)($28) nop addiu $4,$2,%lo($LC2) lw $2,%call16(printf)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,printf 1: jalr $25 nop lw $28,16($fp) b $L10 nop $L9: lb $2,32($fp) nop move $5,$2 lw $2,%got($LC3)($28) nop addiu $4,$2,%lo($LC3) lw $2,%call16(printf)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,printf 1: jalr $25 nop lw $28,16($fp) $L10: move $2,$0 move $sp,$fp lw $31,44($sp) lw $fp,40($sp) addiu $sp,$sp,48 j $31 nop .set macro .set reorder .end main .size main, .-main .ident "GCC: