Question

# I want to know what is wrong with this code, and how to fix it please....

I want to know what is wrong with this code, and how to fix it please. i keep getting

Error using contour (line 48)
Z must be at least a 2x2 matrix.

Error in Projectrevised (line 42)
curve= contour(b,FOS1,h,'ShowText','on');

%% Constants
w = 450000;
l = 10;
n = 6;
SOM = 505000000;
max = 10;
min = 2;
diff = (max-min)/n;
FOS1 = zeros(n,n);
FOS2 = zeros(n,n);
i = 1;
j = 1;
Vm = (w*l)/2;

%% FOS@different base&height values

for b = min:diff:max
for h = min:diff:max
c = (h/2);
density=8000;
V=b*h*l;
mass=density*V;
Mmax = ((w*l^2)/8)*c;
I = (b*h^3)/12;
Bm = (Mmax*c)/I;
Tmax=(3*Vm)/2*(b*h);
Stressmax=(Mmax*c)/I;
FOS1(i,j) = (SOM/Tmax);
FOS2(i,j) = (SOM/Stressmax);
j = j+1;
end
i = i+1;
end

%% Plotting
[B,H]=meshgrid(b,h);
FOS1(i,j) = (SOM/Tmax);
curve= contour(b,FOS1,h,'ShowText','on');
hold on
title('Beam Design')
xlabel('Base (meters)')
ylabel('Height (meters)')
close all
clear plot

If you are plotting a contour plot and plotting z against x and y, then z needs to be a matrix and not a 1 D array.

You are using h to be plotted on z axis, which is an array. However, i see you have converted array h to a matrix H, using meshgrid. So instead of using h, use H.

The command should be

curve= contour(b,FOS1,H,'ShowText','on');

#### Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
• ### Can you please help me with this question. Much appreciated. So I have a sample code,...

Can you please help me with this question. Much appreciated. So I have a sample code, but we need to change the code in a way that fits the problem. A planar slab of material is initially at a temperature of 300 K. At the time t=0, microwave radiation is directed at the material, leading to internal heat generation that is uniform within the material. The sides of the slab experience negligible heat losses and a water bath maintains the...

• ### Hello, i have this matlab code where i have to track a red ball from and...

Hello, i have this matlab code where i have to track a red ball from and uploaded video, and plot its direction in x-y direction My Question is how can i add x vs time plot and y vs time plot in this code. Thank you if exist('V','var') delete(V); end clear;clc; V=VideoReader('video.mp4'); figure(1); x=[];y=[]; i=1; while hasFrame(V) J=readFrame(V); figure(1);imshow(J);title(['Frame No. ',num2str(i)]); if (i>=28 && i<=132) bw=J(:,:,1)>200 & J(:,:,2)<80 & J(:,:,3)<80; bw=imfill(bw,'holes'); A=regionprops(bw,'Centroid'); x(end+1)=A.Centroid(1); y(end+1)=A.Centroid(2); hold on; plot(x,y,'*k');hold off; end i=i+1;...

• ### Cant find what is wrong to fix the code. can you please fix the code. The...

Cant find what is wrong to fix the code. can you please fix the code. The function is: sin^-1 (x/5) #include <iostream> #include <iomanip> #include <math.h> #include <cmath> using namespace std; double f(double x) { return pow(sin, -1)*(x / 5); } int main() { int i, n; double a = 0.0, b =1.0, h, s = 0.0, x, xbar; double s1, s2, s3; cout << " Enter # of partitions n "; cin >> n; cout << " n =...

• ### CAN YOU PLEASE CHECK WHATS WRONG? function[F]=func(t,h) global Atank Ahole kOne kTwo g rho %F=zeros(2,1) %NL=y(1)...

CAN YOU PLEASE CHECK WHATS WRONG? function[F]=func(t,h) global Atank Ahole kOne kTwo g rho %F=zeros(2,1) %NL=y(1) %NG=y(2) F=(kOne+kTwo*cos(2*pi*t/24)-rho*Ahole*sqrt(2*g*h))/(rho*Atank); close all clear all %clear all %close all global Atank Ahole kOne kTwo g rho Atank = 3.13;% Atank value Ahole =0.06; %Ahole value kOne = 300; % K1 value kTwo = 200; % K2 value g = 9.81; % Gravity rho = 1000; % rho value t0=0; tf=150; %range of time %Initial value h0_2=h(1); h0_1=h(2); h0_0=h(3); n=input('Enter the number of steps:');...

Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2*pi*1000*t); figure; plot(t,y1); xlabel('t (second)') ylabel('y(t)') axis([0,.004,-1.2,1.2]) % constrain axis so you can actually see the wave sound(y1,fs); % play sound using windows driver. %% % Check the frequency domain signal. fr is the frequency vector and f1 is the magnitude of F{y1}. fr=([0:no_pts-1]')/no_pts*fs; %in Hz fr=fr(1:no_pts/2); % single-sided spectrum f1=abs(fft(y1)); % compute fft f1=f1(1:no_pts/2)/fs; %% % F is the continuous time Fourier. (See derivation...

• ### I keep getting this error and I do not know how to fix it. this is...

I keep getting this error and I do not know how to fix it. this is the code I've been working on: please help me import java.util.*; public class TelephoneNumber { public static void main(String[] args) {String number; int i=0,j=0; char c; Scanner in=new Scanner (System.in); System.out.println("Enter the phone number: "); number=in.nextLine(); number=number.toUpperCase(); c=number.charAt(i); while(c!='\n'&&j<=7) {switch(c) {case 'A': case 'B': case 'C': System.out.print("2"); j++; break; case 'D': case 'E': case 'F': System.out.print("3"); j++; break; case 'G': case 'H': case'I': System.out.print("4");...

• ### please help! i dont know why there are bugs and how to fix this.. (in C++)...

please help! i dont know why there are bugs and how to fix this.. (in C++) please help! the problem: my code: Create a class called clockType for a clock type with fields hr, min, and sec. Your code should support the following set of statements 1 clockType c1; 2 clockType c2 (10,59); 3 clockType c3(5,10,20); 4 int sec = 10; 5 cout << c1; cout << c1+c2; In c2, you only set hr and min fields. Note that the...

• ### why is this wrong for vectors vector<char> decrypt{ {'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',...

why is this wrong for vectors vector<char> decrypt{ {'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A'}, {'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'}, }; for(int...

• ### I know that my work is correct. I know that delta U is not 0, and...

I know that my work is correct. I know that delta U is not 0, and delta H is not 0. How do I complete this problem? For a Van der Waals gas, the following equations hold. P= nRTIV-nb) - a[n/v2 dU = CydT+ a(n/V)2 dv For chlorine gas, Cvm = 25.6 JK-1 mol-t, a = 6.343 bar L2 mol-2, and b = 0.0542 L molt Calculate q, w, AU, and AH, in joules, when one mole of chlorine gas...

• ### please provide matlab solution too 3. Butterball recommends the following cooking times for turkeys at 325...

please provide matlab solution too 3. Butterball recommends the following cooking times for turkeys at 325 °C. size, (lbs) un-stuffed t, (h) stuffed t, (h) 2.00 2.25 6. 2.50 2.75 10 3.00 3.50 18 3.50 4.50 22 4.00 5.00 24 4.50 5.50 30 5.00 6.25 (a) Plot the recommended cooking time as a function of turkey size for un-stuffed and stuffed turkeys on the same plot. (b) For each of the two menu options, find the third-order interpolating polynomial (by...