Matlab won't plot a graph of my data?

29 次查看(过去 30 天)
I'm currently plotting a simple data table of excel data (a 12445 by 8 table where the first column is the x axis and the rest of the columns are multiple plots on the same graph (using the hold on function) Now I've had this issue before but this time I just can't seem to shake it - not sure if it's a glitch. I broke the code down from the more efficient script I wrote to see whether I could place breakpoints and see where the issue lay. So far I have:
x = KAcConcentrationsat130K.WaveNumber(2:12445);
y2 = KAcConcentrationsat130K.VarName2(2:12445);
figure
plot(x,y2)
title('KCH_3COO Varying Concentrations at 130K')
xlabel('Frequency (cm^-^1)')
ylabel('Absorbance')
hold on
y3 = KAcConcentrationsat130K.VarName3(2:12445);
plot(x,y3)
However, MATLAB does not plot the graph. No figure windows come up and instead it just prints every integer value of data (atleast 12000 values) out in the command window. Has anyone got an idea of how to stop it from printing the data out in the command window and plot it instead?
  3 个评论
Rik
Rik 2018-2-17
I suspect that something overwrote the internal plot function, so by running the line of code below, you can find out if this is the case.
which plot

请先登录,再进行评论。

回答(3 个)

Image Analyst
Image Analyst 2018-2-17
In the command window, do this:
>> which -all plot
Tell us what you see. You might see this:
>> which -all plot
built-in (C:\Program Files\MATLAB\R2017b\toolbox\matlab\graph2d\plot)
C:\Program Files\MATLAB\R2017b\toolbox\matlab\polyfun\@polyshape\plot.m % polyshape method
C:\Program Files\MATLAB\R2017b\toolbox\matlab\polyfun\@alphaShape\plot.m % alphaShape method
C:\Program Files\MATLAB\R2017b\toolbox\matlab\bigdata\@tall\plot.m % tall method
C:\Program Files\MATLAB\R2017b\toolbox\matlab\graphfun\@graph\plot.m % graph method
C:\Program Files\MATLAB\R2017b\toolbox\matlab\graphfun\@digraph\plot.m % digraph method
C:\Program Files\MATLAB\R2017b\toolbox\signal\signal\@dspdata\plot.m % dspdata method
C:\Program Files\MATLAB\R2017b\toolbox\stats\classreg\@LinearModel\plot.m % LinearModel method
C:\Program Files\MATLAB\R2017b\toolbox\matlab\timeseries\@timeseries\plot.m % timeseries method
If you see anything that says plot is a variable, that's a problem because it means that you made a variable with the same name as a crucial built-in function and it's using that variable instead of the built-in function. And since you didn't put the semicolon at the end of the line, it's printing all the values to the command window.
Or you could put that line of code directly into your script, before you call plot(), and see what it prints out. From the sounds of it, chances are high that you defined a variable called plot. Search for everywhere in your code that you used plot by typing control-shift-f.
  5 个评论
Nicola Fairbairn
Nicola Fairbairn 2018-2-19
编辑:Nicola Fairbairn 2018-2-19
So I've changed the column variables and nothing has fixed. It seemed to run fine on a different computer in the lab, not sure whether its a glitch. There is nothing in the Workspace with a generic name. Thoughts?
Walter Roberson
Walter Roberson 2018-2-19
When you say the issue has come back, do you mean your code is displaying a bunch of data as indicated in your original post?
In order for the current code to be displaying a bunch of data, NaTFAcooling.WaveNumber would have to be a function that displayed data, or else title or xlabel or ylabel would have to be something different than their normal function. It would not be enough for plot to have become a variable as you have the semi-colon at the end of the line that would block output; the same for set

请先登录,再进行评论。


Nicola Fairbairn
Nicola Fairbairn 2018-2-18
I took out some unnecessary data that I didn't need (I only really cared about 4000 rows of the 12000) and it seemed to work yesterday, I will run it tomorrow and let you know what happens.

Eddie Murray
Eddie Murray 2023-8-11
Why Do I Get This When I Try To Run A Graph In MATLAB
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceCamera
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during reparentChildren
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Could not find node in peer tree during replaceChild
Warning: An error occurred while drawing the scene: Error in json_scenetree: Could not find node in replaceChild
Warning: An error occurred while drawing the scene: Error in json_scenetree: Could not find node in replaceChild
  1 个评论
Image Analyst
Image Analyst 2023-8-11
Probably an error in the program you wrote.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by