Question
MATLAB question: I have some data on excell and I have to write a code that does the following:

Read from Data_all.xlsx Sheet “Wave_data, your specific Wave Height (WH) measurements and using a for loop and if-elseif-
Please use dummy data for your convenience.

Thank you in advance for your help!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the MATLAB code to perform the specified task.

 clear; clc; FileName = 'Data_all' %Keep the file in the same folder as .m file num = xlsread(FileName); %Read data from excel sheet %Initialize counters a=0; b=0; c=0; d=0; e=0; f=0; g=0; for i = 1:1:length(num) if num(i) == 0 | num(i) == 1 a = a+1; elseif num(i) == 2 | num(i) == 3 b = b+1; elseif num(i) == 4 | num(i) == 5 c = c+1; elseif num(i) == 6 | num(i) == 7 d = d+1; elseif num(i) == 8 | num(i) == 9 e=e+1; elseif num(i) == 10 | num(i) == 11 f = f+1; elseif num(i) == 12 | num(i) == 13 g =g+1; else disp("Invalid Input"); end end y = [ a b c d e f g]; name = {'0-1';'2-3';'4-5';'6-7';'8-9'; '10-11'; '12-13'}; x = [1:7] %For X- axis %figure(1); %Uncomment these two lines for having subplot in your next task %subplot(2,1,1); bar(x,y) %Plot Bar graph xlabel('Wave height in meters'); %Label on X-axis ylabel('Number of waves'); %Label in Y-axis set(gca,'xticklabel',name); %Set wave height for each bar in graph

The following screenshot will help you with the indentation:

TII IIIIIIIIIIIIIIIIIIIIIIIIIII clear; clc; FileName = Data_all Keep the file in the same folder as .m file num = xlsread (

After giving the random numbers from 0 - 13 from excel sheet as follows:

The output will be as follows:

- OX Figure 1 Eile Edit View Insert Tools Desktop Window Help Number of waves 0-1 2-3 10-11 12-13 4-5 6-7 8-9 Wave height in

Uncomment the figure(1) and subplot(2,1,1); for subplot in your next task.

Note: Feel free to reach me out using the comment section if needed help. Please give a thumbs up for the solution. Thanks in advance.

Add a comment
Know the answer?
Add Answer to:
MATLAB question: I have some data on excell and I have to write a code that...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  •    MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each...

       MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each plot should have its own figure associated with it. In all questions, give the figure a title, and label the acis. Save your matlab script as drill 10.m Do not use the fplot command. 1. Plot the function f(x) = (x + 5)2 for -5 <<<10. Include a plot title, and label both aris. 2. Use the subplot command to make two plots of...

  • Use matlab a) Create a simulated data set b) Create a set of plots to determine...

    Use matlab a) Create a simulated data set b) Create a set of plots to determine the best transformation to linearize the data c) Fit a first order polynomial (y mx + b) to the linearized data to find the constants m and b d) Reconstruct the original equation from m and b in the linear fitted polynomial e) Plot the fitted equation. Radioactive decay is modeled by the equation: rt where A the amount of mass as a function...

  • I need help solving these questions,please don’t know how to solve it by using matlab.!

    i need help solving these questions,please don’t know how to solve it by using matlab.! Solve the following questions Ol: You are required to develop a script to calculate the volume of a pyramid, which is 1/3 *base *height, where the base is length *width. Prompt the user to enter values for the length, width, and height, and then calculate the volume of the pyramid. When the user enters each value, he or she will then also be prompted to...

  • please help me with this MATLAB CODE and explain to me what each line does and...

    please help me with this MATLAB CODE and explain to me what each line does and what is used for? leave your comments as words, not as pictures. ..................................................................................................................................................................... clear all; close all; % For a script file, you better start with clear all and close all                        % However, for a fucntion, you better NOT to start                        % with them %% End of cell mode example %% Plot function t = 0:0.1:5; x1 = sin(2*5*t); x2 = cos(3*7*t);...

  • matlab is mathematics programing language.you have to write code of matlab, with your output screen shot...

    matlab is mathematics programing language.you have to write code of matlab, with your output screen shot of waveform Problem 6 Matlab: For a baseband message signal m(t) = 5cos(250t), and carrier signal c(t) = cos(2103t). Sketch the FM modulated signal in time domain in the interval (0, 0.1 seconds without using pmmod function in Matlab, for (a) kp = 7/2 rad/V (b) kp = 7/4 rad/V Verify and report your results using the MATLAB command pmmod, for different ky as...

  • please I need help with excel or matlab part. part 3 Lab 1 BASIC DATA PROCESSING...

    please I need help with excel or matlab part. part 3 Lab 1 BASIC DATA PROCESSING PRE-LAB ASSIGNMENT 1. Read the lab manual carefully so you know what you have to do when you walk into the lab. 2. In a lab, the resistance of a resistor was measured using 50 samples giving the following values: 119.95 (6), 121.32 (5), 119.57 (7), 117.43(1), 120.76 (15), 120.67 (1), 119.78 (8), 121.43(3), 121.82(1), and 118.47 (3) 2 Estimate the average value of...

  • MATLAB question I need the code exactly as you would write it in MATLAB. thank you...

    MATLAB question I need the code exactly as you would write it in MATLAB. thank you 1. Consider a Gaussian solution of the traveling-wave form ψ(z,t)-exp(-a(z-vt)2). The parameter values are a 1, 2. (a) Explain the physical meaning of these parameters (eg. what would happen if we took a = 10 instead?) Determine the direction of propagation of this solution: Is it traweling to the left or to the right? (2pts) (b) Write a Matlab code to plot the Gaussian...

  • Please help with this code For the following problem write a Matlab® script file with clear...

    Please help with this code For the following problem write a Matlab® script file with clear commentary for each line of code. Your script should: Load the data in the problem as a text file. Calculate the statistics using Matlab  functions. Solicit input from the user of the reading (for example, 137 degrees as stated in the problem). In another word, the reading should not be fixed in the script and has to be entered and saved from the command window...

  • Please help me with this MATLAB programming problem! Im coding iin MATLAB2018 if that makes any d...

    Please help me with this MATLAB programming problem! Im coding iin MATLAB2018 if that makes any difference! The first picture is the question i need to answer. The picture below is used as reference to answer the question. The last picture (below) is the into to the problem, and is used as reference. 1. Use Matlab to create the following single plot with three subplots. All titles, gridlines, and axis labels should be as shown. Arc System Response 15 E...

  • 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;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT