Question

In: Computer Science

MATLAB Create a function that prints a string of perfect cubes between (m,n). Include any reasonable...

MATLAB

Create a function that prints a string of perfect cubes between (m,n). Include any reasonable error statements such as decimals and negative numbers.

Solutions

Expert Solution

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clc
clear all
m=input('Enter m: ');
if(m<0||m~=floor(m))
disp('Error! Input m is not accepted');
return;
end
n=input('Enter n: ');
if(n<0||n~=floor(n))
disp('Error! Input n is not accepted');
return;
end
fprintf('Perfect cubes are: ');
for i=m:n
if(abs(i^(1/3)-round((i)^(1/3)))<1e-10)
fprintf('%d ',i);

end
end

Kindly revert for any queries

Thanks.


Related Solutions

create a function in matlab that sums two m x n matrices using nested loops, then...
create a function in matlab that sums two m x n matrices using nested loops, then returns result into a new matrix. Use nesed for loops to add matrices piece by piece. Basically means, dont program simply A+B Function should perform error check to make sure both matrices have same number of rows/ columns.
Python Programcomplete theprocessString(string)function. This function takesin a string as a parameter and prints the...
Python Program complete theprocessString(string)function. This function takes in a string as a parameter and prints the average number of characters per word in each sentence in the string. Print the average character count per word for each sentence with 1 decimal precision(see test cases below).-Assume a sentence always ends with a period (.)or when the string ends. -Assume there is always a blank space character(" ")between each word. -Do not count the blank spaces between words or the periods as...
Python please! Create one program to include all 10 elements: Create a function that prints a...
Python please! Create one program to include all 10 elements: Create a function that prints a sentence passed to the function as parameter. On the next line, print the same sentence without the 1st and the last character, use string slicing. Use the following sentence: This is the sentence. Given a string: This string was copied in an article. Replace the relevant words to read as follows: This string was discovered in the article xyz. Given a string: This string...
Matlab Create/write a function that takes an input of x and y data, and a string...
Matlab Create/write a function that takes an input of x and y data, and a string (either linear? or quadratic), sets up a linear system of equations (Ax = b), and solves and plots the model.
In MATLAB Write a function to create an array of N numbers with a normal distribution....
In MATLAB Write a function to create an array of N numbers with a normal distribution. Call that from a script to create 1000 numbers, with a mean of 50 and a sigma of 10.
Matlab program Create a function, when given a two-digit integer as input, prints the equivalent English...
Matlab program Create a function, when given a two-digit integer as input, prints the equivalent English phrase. For example, given 39, output thirty-nine. Limit the input numbers to be in the range 21 to 39.
This function takes in a string as a parameter and prints the average number of characters...
This function takes in a string as a parameter and prints the average number of characters per word in each sentence in the string. Print the average character count per word for each sentence with 1 decimal precision (see test cases below). Assume a sentence always ends with a period (.) or when the string ends. Assume there is always a blank space character (" ") between each word. Do not count the blank spaces between words or the periods...
Create a Java program which prints a truth table for any 2 variables propositional function. Assuming...
Create a Java program which prints a truth table for any 2 variables propositional function. Assuming variables p and q. Instead of the symbols for "and" and "or", just used the words. For "not", use the tilde "~" Prompt the user for 3 questions 1: "p and q"? Or "p or q"? 2: Do you want to negate p? 3: Do you want to negate q? For example, suppose in a menu system the user chose "p or q", and...
In Java, write a recursive function that accepts a string as its argument and prints the...
In Java, write a recursive function that accepts a string as its argument and prints the string in reverse order. Demonstrate the function in a driver program.
Using Matlab, write a function that takes numeric data as its input argument and prints a...
Using Matlab, write a function that takes numeric data as its input argument and prints a message to the Command Window stating if the number is positive, or negative, or 0. This function should transfer an output value to the Workspace ONLY when the input value is negative. Please include a copiable code and the associated screenshots.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT