The "subplot" command in MATLAB

The "subplot" command in MATLAB

Everytime I try the subplot command in Matlab command window, it says rectangular wave instead of showing the description about it. I tried reinstalling it but problem persists.

The funny thing is, the same version of MATLAB in my friend’s laptop shows correct output. I actually tried another version of MATLAB, but that did not solve the problem. Can someone help me figure out the problem and its fix?

Answer:

Based on your description, it seems like your MATLAB environment might have been corrupted or there might be some code running automatically which is redefining the built-in "subplot" function. Here are a few steps you can try to solve this:

  1. Check for name conflict: There could be a user-defined function or script named "subplot" in your MATLAB path that's overriding the built-in MATLAB function. Type which subplot -all in the command window. If there is more than one file named subplot, MATLAB is likely using the one that appears first, which might not be the built-in function. If that's the case, you need to either rename the user-defined function or change the MATLAB path order.

  2. Clear Function: MATLAB caches information about functions for performance. Use the clear function command to remove all functions from the memory.

  3. Reset MATLAB path to default: Use the command restoredefaultpath to reset your MATLAB path to its default state.

  4. Start MATLAB with no startup files: In some cases, the MATLAB startup might contain commands that redefine "subplot". Starting MATLAB without these files can help identify the issue. You can do this by opening the MATLAB executable with the -nodesktop -noFigureWindows command line options.

  5. Check your startup folder: MATLAB runs the startup.m file located in the MATLAB startup directory when it starts. Check this file for any redefinitions of the subplot function.

  6. Reinstall MATLAB: If all else fails, you may need to reinstall MATLAB. But before you do that, make sure to remove all settings and files related to MATLAB from your system, including in the user directory and the system directories.

These solutions should help you debug the problem. You may want to check out the MATLAB user community or MATLAB's own technical support if the issue continues to persist. They might have encountered similar issues and could provide additional solutions.

Replies

  • Jeffrey Arulraj
    Jeffrey Arulraj
    Come on a little more insight to u?

    Sub plot command allows us to create axis based representation of the parameter

    Can you please post the code snippet which gave you that output?

    Then we can see what is the bug and also tell if there is any graph displayed when you use that command
  • dhruba sunuwar
    dhruba sunuwar
    Jeffrey Samuel
    Come on a little more insight to u?

    Sub plot command allows us to create axis based representation of the parameter

    Can you please post the code snippet which gave you that output?

    Then we can see what is the bug and also tell if there is any graph displayed when you use that command
    here's a simple code using subplot that i typed in the matlab.

    t=0:0.01:05
    x=sin(2*pi*5*t)
    subplot(2,1,1)
    plot(t,x)
    y=cos(2*pi*5*t)
    subplot(2,1,2)
    plot(t,y)
    grid


    above code should show two sinusoidal waves in a window, but instead it shows this error:

    "??? Attempt to execute SCRIPT subplot as a function:
    C:\Users\itechstore\Documents\MATLAB\subplot.m

    Error in ==> tttss1 at 3
    subplot(2,1,1)
    "

    so, what might be the problem and the solution to it!!!
  • Jeffrey Arulraj
    Jeffrey Arulraj
    Did you by chance save a file in the name of Subplot.m

    Looks like the base code of that file has been tweaked a little.

    Do follow that file path you have provided to us and check the source file? if it has been altered or changed to other then kindly revert those changes.
  • dhruba sunuwar
    dhruba sunuwar
    Jeffrey Samuel
    Did you by chance save a file in the name of Subplot.m

    Looks like the base code of that file has been tweaked a little.

    Do follow that file path you have provided to us and check the source file? if it has been altered or changed to other then kindly revert those changes.
    no, i haven't saved the file in that name. and the base code too hasn't been altered. when "help subplot" is typed in the command window it should show information and syntax of "subplot" but it just shows "rectangular wave"... but the same version of matlab when installed in other pcs of laptops does show the information when typed "help subplot".... i guess my laptop has fault rather than the software... does having an expired antivirus have any effect on the matlab files?

You are reading an archived discussion.

Related Posts

How to learn MYSQL?
To be clear, you won’t be getting any R2-D2 stuff, so don’t get your hopes ‘that high’. Having said that, a flying device that you can control via your iphone...
If you thought that every other tech giant now seems eager to track your health, hold on to your hats. Guess who might just foray into this business? It's none...
This post is intentionally edited for personal reasons! 😔😖
how to become good computer science engineers. learning more and more languages or becoming good in some.