Erick asked . 2024-05-03

How to use operations in for loop problems ?

For values of 1 to 60, create a for-loop that does the following. If the value is 1 to 20, have
the operation be number2, if the value is 21 to 40, have the operation be number, and if the
value is 41 to 60, have the operation be number. Store all 60 results in 3 different variables
that start at 1. With the results, create a 3x20 matrix where the first row is the results of the
first operation, the second row being the results of the second operation, and the final row
being the results of the final operation

MATLAB , Language Fundamentals , Loops and Conditional Statements , operations , matrix

Expert Answer

Neeta Dsouza answered . 2024-05-18 20:38:26

For this task, you can use for loop as follows

 

A = zeros(3,20);
for ii = 1:60
    if ii<=20
        A(1,ii) = ii^2; %first operation
    elseif ii<=40
        A(2,ii-20) = ii; %second operation
    else
        A(3,ii-40) = sqrt(ii); %third operation
    end
end
disp(A)
  Columns 1 through 18

    1.0000    4.0000    9.0000   16.0000   25.0000   36.0000   49.0000   64.0000   81.0000  100.0000  121.0000  144.0000  169.0000  196.0000  225.0000  256.0000  289.0000  324.0000
   21.0000   22.0000   23.0000   24.0000   25.0000   26.0000   27.0000   28.0000   29.0000   30.0000   31.0000   32.0000   33.0000   34.0000   35.0000   36.0000   37.0000   38.0000
    6.4031    6.4807    6.5574    6.6332    6.7082    6.7823    6.8557    6.9282    7.0000    7.0711    7.1414    7.2111    7.2801    7.3485    7.4162    7.4833    7.5498    7.6158

  Columns 19 through 20

  361.0000  400.0000
   39.0000   40.0000
    7.6811    7.7460

 


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.