Question

USING MATLAB...Write a function that creates a structure variable called createSpacecraft. The function should take four...

USING MATLAB...Write a function that creates a structure variable called createSpacecraft. The function should take four inputs, a number called mass (in kg), a number called fuel (in joules of energy), a number called orbit (in meters), and a number called engine (in newtons). It should return an output structure called spacecraft containing each of those values. Please ensure that both the function name, AND the names of variables within the spacecraft structure are exactly as instructed

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Function:

function spacecraft = createSpacecraft (mass, fuel, orbit, engine)
% Function that creates the spacecraft structure with the given fields
  
% Creating SpaceCraft
spacecraft = struct("mass",mass,"fuel",fuel,"orbit",orbit,"engine",engine);
  
end % function end

__________________________________________________________________________________________________

Sample Run:

Add a comment
Know the answer?
Add Answer to:
USING MATLAB...Write a function that creates a structure variable called createSpacecraft. The function should take four...
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
  • PLEASE ONLY DO D IN MATLAB. I DID A B AND C, dont need them. Intro...

    PLEASE ONLY DO D IN MATLAB. I DID A B AND C, dont need them. Intro to Computers for Engineers Recitation 11 In today's class, we are modeling a spacecraft. Please submit all functions you write. Pay very careful attention to names. If you name a function differently from what you are instructed, things might not work. Test your code using the scripts siml.m and sim2.m before trying to submit on zyLabs. A. [Submit on zyLabs] Write a function that...

  • answer in matlab please Create a separate function file fieldtovar.m that receives a single structure as...

    answer in matlab please Create a separate function file fieldtovar.m that receives a single structure as an input and assigns each of the field values to user-defined variables. The function should work for a structure with any number of fields. Additionally, implement an error check to ensure that the number of user- defined variables (output arguments) is equal to the number of structure fields. Here are two examples of calling the function: » Boeing_747 = struct('Length', 70.6, WingSpan', 64.4, 'Engine',...

  • Using MatLab Write a function called PrimeFinder that receives an integer n as an input argument,...

    Using MatLab Write a function called PrimeFinder that receives an integer n as an input argument, and provides an output argument called Primes that is a vector containing all prime numbers between 2 and n, inclusive. Verify the correctness of your code with inserting 13 as the input argument, and check that your output is Primes = [2,3,5,7,11,13]. You are NOT allowed to use any directly relevant MATLAB built-in function such as divisors, etc. NOTE: A prime number is a...

  • Problem 3: Write a MATLAB function called cubic_spline to compute the natural cubic spline for a...

    Problem 3: Write a MATLAB function called cubic_spline to compute the natural cubic spline for a given data set. The x and y data points and the rdesired values (a vector) should be the inputs, and the corresponding ydesired values (a vector) should be the output.

  • PYTHON The first function you will write should be called ‘countDown’. Your function should take zero...

    PYTHON The first function you will write should be called ‘countDown’. Your function should take zero (0) arguments. The function should return one (1) list containing integers from 10 to 1 and finally, the string “Liftoff!”. (i.e., [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, ‘Liftoff!’]). You function must be recursive (i.e., it should contain a call to itself within the function body). You will get NO credit if you use any loops (for, while, etc). 3. Function...

  • ·Write a Cl Calculator in MATLAB (function name ci_calc.m). Your function should take four input arguments:...

    ·Write a Cl Calculator in MATLAB (function name ci_calc.m). Your function should take four input arguments: σ, x,n, p% Confidence Interval Calculator σ (Std Dev) Sample mean Sample size Confidence level 577.4 37.4556 100 90% Numeric input Numeric input Numeric input Numeric input Lower limit of Cl -57.52 Numeric output Upper limit of Cl 132.43 Numeric output

  • 8. Write a MATLAB function that will take as inputs a set of data (x,y) and...

    8. Write a MATLAB function that will take as inputs a set of data (x,y) and output the best estimate of the integral using a Romberg Array. The function should perform two trapezoidal integrations using the full interval and half the interval, and then combine these integrations in a Romberg Array. Your function should also output the relative error of the integral. Please note that the data entered may not be evenly spaced and your function should make sure that...

  • MATLAB Only MATLAB Only MATLAB Only Indicated in the script below, write a function, called arbpoly3,...

    MATLAB Only MATLAB Only MATLAB Only Indicated in the script below, write a function, called arbpoly3, that accepts two inputs: i) a row vector, called c, containing the coefficients of the polynomial, starting with the coefficient for the lowest degree term, which is the constant term. ii) a row vector, called x, which is the set of real numbers where the polynomial is to be evaluated. The output, y, will be a vector containing the values of the polynomial, evaluated...

  • MUST BE DONE IN MATLAB! Test inputs Write a function called CheckInputs which checks if three...

    MUST BE DONE IN MATLAB! Test inputs Write a function called CheckInputs which checks if three inputs parameters are the correct data types. The first second, and third input variables must be a string, numeric, and logical data type, respectively. The output of Checkinputs should be a logical row array, errorCode with 4 values If all the tests pass, then errorCode should consist of only false values. If the 1st input parameter is not a string, the 1st array element...

  • Write a Matlab function called sine_Taylor that inputs a positive integer n, a number x, and...

    Write a Matlab function called sine_Taylor that inputs a positive integer n, a number x, and outputs the nth Taylor polynomial of the sine function. Compute the absolute and error for n = 1: 10 at x = 1, obtained by comparing the output of your function to that of Matlab's built in sine function. Type on the Matlab console format long, then compute the previous error. Repeat the operation by typing format short. Comment on the result (quantify the...

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