Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 5 (10 points). Improve the following inefficient code with nested loops by using vectorization method. Hint: you should use meshgrid for this problem. (X,Y,Z]

image text in transcribed

Problem 5 (10 points). Improve the following inefficient code with nested loops by using vectorization method. Hint: you should use meshgrid for this problem. (X,Y,Z] = meshgrid(xgv, ygv, zgv) produces three-dimensional coordinate arrays. The output coordinate arraysX.Y and Z contain copies of the grid vectors xgv, ygv, and zgv respectively. The sizes of the output arrays are determined by the length of the grid vectors. For grid vectors xgv, ygv, and zgv of length M, N, and P respectively, X,Y, and Z will have N rows, M columns, and P pages. clear all; clc; YOUR ANSWER: clear all; clc; calculating f(x, y, z)=y/ (1+x2)+y"2*sin(z) calculating f(x, y, z)=y/ (1+x^21+y^ 2 * sin (2) by using vectorization method at some discretized points of a 3D volume. at some discrete points of a 3D volume x-linspace (-10,10,100) y-linspace (-10,10,200) z-linspace (-10,10,300) for i=1:length (x) x=linspace (-10, 10, 100) ; y-linspace (-10,10,200) z-linspace (-10,10,300) for j=1:length (y) for k-l:length (z) E(i,j,k)-((1x (i) 2) +y (j) A2*sin (z (k)); end end end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

Find the oblique asymptote for F(x) = 3x3 + 4x2 - x + 1 / x2 + 1

Answered: 1 week ago