Question

MATLAB question! PLEASE HELP Create a function that returns true if the input is a scalar...

MATLAB question! PLEASE HELP

Create a function that returns true if the input is a scalar value (i.e. of size 1x1) of class type double and false otherwise.

• Function Name: isScalar

• Input: single input which may be any data class

• Output: the output is true or false

• Useful functions: size(), class(), strncmp()

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

`Hey,

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

clear all
clc
isScalar('fhjk')


function y=isScalar(A)
   [m,n]=size(A);
   if(m==1&n==1&strcmp(class(A),'double')==1)
       y=true;
   else
       y=false;
   end
end

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
MATLAB question! PLEASE HELP Create a function that returns true if the input is a scalar...
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: write a function that retuns logical true of vector or matrics or scaler is empty...

    MATLAB: write a function that retuns logical true of vector or matrics or scaler is empty Write a function that retuns logical true of vector or matrics or scaler is empty %% P2: Check for an empty matrix % Write a function myIsEmpty which takes one input (scalar, vector, matrix, ...) % and returns logical true if the input is empty and false otherwise. % DO NOT USE MATLAB's isempty FUNCTION! % % Example: An input of [] should result...

  • In matlab, there is a function "size" that accepts an array as a parameter (or input...

    In matlab, there is a function "size" that accepts an array as a parameter (or input argument) and returns the dimensions of that array as another single-dimension array.      For example, if the array were 2 x 2, it would return [2 2]. Assume that input1 is a 1 or 2-dimensional array. Use the size function to obtain the dimensions and save the output into the return argument of this function "output1"     1Do not modify the line below 2-unction...

  • Create a recursive method that takes as input the root Node of a tree and returns true if the N v...

    Create a recursive method that takes as input the root Node of a tree and returns true if the N variable of each node within that tree has the correct value (i.e., all nodes are labeled with the proper size of the subtree they define), and false otherwise.

  • please help with this simple MATLAB function 1 Grades Search function grade - searchGrade (name, scores.lab04)...

    please help with this simple MATLAB function 1 Grades Search function grade - searchGrade (name, scores.lab04) Input Type Description name 1xNchar a name in the scores lab04.mat file for- matted with last name followed by first name and no spaces or capitalization (see details) scores.lab04) Nx2 cell the name(s) and the score(s) in the scores.lab04.mat file Output Type Description grade 1x1 double The score recieved by name Details You happened to have acquired a file called scores lab04.mat with the...

  • Please write the code using matlab 1) i. Create an anonymous function named optimist, that accepts...

    Please write the code using matlab 1) i. Create an anonymous function named optimist, that accepts a single variable as input i Create a row vector Tthat represents the number of seconds in two minutes, starting ii. Call the function optimist on the vector T, store the result in variable R1 and returns the double of that variable from one and ending at a hundred and twenty v. Create an anonymous function named pessimist, that accepts a single variable as...

  • Write a function is_mirror(s) that takes as input a string s and returns True if s...

    Write a function is_mirror(s) that takes as input a string s and returns True if s is a mirrored string (i.e., a string that could have been produced by your mirror function) and False otherwise. Examples: >>> is_mirror('baconnocab') result: True >>> is_mirror('baconnoca') result: False Warning Your function should return a boolean value – either True or False, without any quotes around them. If you see quotes around the result when you make the calls above from the console, you must...

  • matlab 3. Write a function called MessageDecode that matches an input string scalar to a known...

    matlab 3. Write a function called MessageDecode that matches an input string scalar to a known text message abbreviation, and output the unabbreviated form if known. Otherwise, output “Unknown message”. Support the abbreviations: BFF—best friends forever • BTW-by the way • IDK—I don't know • IMHO—in my humble opinion • LOL—laughing out loud • TMI—too much information Restriction: use switch statement. For example, >> myString="BFF"; >> MessageDecode (myString) ans- "best friends forever" (Hint: part of the code may like: switch...

  • Matlab for engineers 5th edition please help me with this problem with explanation. Consider the following...

    Matlab for engineers 5th edition please help me with this problem with explanation. Consider the following mathematical expression to create a single input-output function. y= −x​3+ x​2 + 2 a)Create a single input-output function that can accept scalar and matrix values. b)Plot the output versus the input, and properly label the axes and add a title. Note: the plot command should be coded inside the function file. c)Calculate y values for x= [−10, 10] with an appropriate increment.

  • sorted vowels Write a function that returns true if the vowels in the input string A...

    sorted vowels Write a function that returns true if the vowels in the input string A appear in non-decreasing order and false otherwise. You can assume this function is not case sensitive. If the string does not contain any vowels, it must return true. bool sorted_vowels (const char A)

  • Write the definition of a function that takes as input the three numbers. The function returns...

    Write the definition of a function that takes as input the three numbers. The function returns turn if the first number to the power of the second number equals the third number otherwise it returns false. Assume that the three numbers are of type double. Use paw() function for the power.

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