Question

This is the code I am working on for a project using MATLAB: clc,clear G=27.7*10.^9; b=0.286*10.^-9;...

This is the code I am working on for a project using MATLAB:

clc,clear
G=27.7*10.^9;
b=0.286*10.^-9;
v=0.334;
x=(-5*10.^-9:0.1:5*10.^-9);
y=(-5*10.^-9:0.1:-1*10.^-9);
[xx,yy]=meshgrid(x,y);
stress=(-G*b)*yy*(3^xx+yy^2)/(2*pi.*(1-v))*(xx^2+yy^2).^2;
figure
mesh(xx,yy,stress);
grid on
xlabel('X')
ylabel('Y')
zlabel('Stress')

Whenever I try to run this I keep getting the "Error using mesh" line, and then an error for "mesh(xx,yy,stress)".
I know I am not catching the issue but how do I fix this? If you could explain as well that be extremely helpful!

Homework Answers

Answer #1

Following is the fixed code :


clc,clear
G=27.7*10.^9;
b=0.286*10.^-9;
v=0.334;

%
% FIX : Use proper increments for x and y, to create vectors.
%
x=(-5*10.^-9:0.1*10.^-9:5*10.^-9);

%
% FIX : Use proper increments for x and y, to create vectors.
%
y=(-5*10.^-9:0.1*10.^-9:-1*10.^-9);


[xx,yy]=meshgrid(x,y);


%
% FIX : Use dot-operations between vectors, so that "stress" is also a vector.
%
stress=(-G*b).*yy.*(3.^xx+yy.^2)./(2*pi.*(1-v)).*(xx.^2+yy.^2).^2;


figure
mesh(xx,yy,stress);
grid on
xlabel('X')
ylabel('Y')
zlabel('Stress')

Following is the plot :

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am using matlab and getting a "matrix dimensions error below" for line 22. Can someone...
I am using matlab and getting a "matrix dimensions error below" for line 22. Can someone spot the error and try the code to fix the error. %The beginning step is to generate a functionf(t) that consists of the sum %of the following components % 25 Hz cosine function of magnitude 1 % 50 Hz sine function of magnitude 1 % 40 Hz square wave function of magnitude 1 clear; clc; close all; %sample rate is given at 2500 Hz...
Problem 3 you can use Matlab and also i give u the Problem 1 code its...
Problem 3 you can use Matlab and also i give u the Problem 1 code its on Matlab Using the same initial code fragment as in Problem 1, add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR bandpass filter with band edge frequencies 750 Hz and 850 Hz and based on a 4th order Butterworth prototype. Name your program p3.sce this is the Problem 1 code and the solutin clear; clc;...
Question : Design the low and high pass filter for the signal, x(t) = 10 sin...
Question : Design the low and high pass filter for the signal, x(t) = 10 sin (10 t) + 1 sin (1000 t) by MATLAB Is below answer right? at ?High pass , 5row shouldn't this change from sin(100*t) ? sin(1000*t) x = 10*sin(10*t) + 1*sin(100*t); ?   x = 10*sin(10*t) + 1*sin(1000*t); ??? ..................................................................................................................................................... ?Low pass clc; rng default Fs=2000; t=linspace(0,1,Fs); x=10*sin(10*t)+sin(1000*t)%given signal n=0.5*randn(size(t));%noise x1=x+n; fc=150; Wn=(2/Fs)*fc; b=fir1(20,Wn,'low',kaiser(21,3)); %fvtool(b,1,’Fs’,Fs) y=filter(b,1,x1); plot(t,x1,t,y) xlim([0 0.1]) xlabel('Time (s) ') ylabel('Amplitude') legend('Original Signal','Filtered Data')...
For some reason I followed the steps in my project and I am getting the incorrect...
For some reason I followed the steps in my project and I am getting the incorrect output and when I am submitting it, it gives me compilation error. Printing empty array -- next line should be blank Testing append: Shouldn't crash! Should print 100 through 110 below, with 110 on a new line: 100 101 102 103 104 105 106 107 108 109 110 Checking capacity of new array: OK Append test #2: Should print 100 through 120 below, on...
I keep getting error working on my project 2 MAT 243. What am I doing wrong?...
I keep getting error working on my project 2 MAT 243. What am I doing wrong? Step 3: Hypothesis Test for the Population Mean (I) A relative skill level of 1420 represents a critically low skill level in the league. The management of your team has hypothesized that the average relative skill level of your team in the years 2013-2015 is greater than 1420. Test this claim using a 5% level of significance. For this test, assume that the population...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT