How to clear all fitting settings?

조회 수: 3 (최근 30일)
odo22
odo22 2016년 7월 21일
댓글: odo22 2016년 7월 21일
I'm plotting some data from a 2068 by 5 matrix (spectra.m) using this code:
load 'spectra.mat'
hold on
for i = 2:5
plot(spectra(:,1), spectra(:,i), 'LineWidth', 7)
end
Every time I run the script, it comes up with a plot of the data as expected but each line has linear fit to it (see picture). Though I'm not sure if it's a fit or some other effect...
I've already tried clearing the work-space and restarted Matlab, in case I've inadvertently changed some settings. However, this didn't make any difference...In fact, if I plot some data from other projects, everything works fine so there must be a problem with the way I'm plotting the matrix!
Any help would be very much appreciated :)
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 21일
The provided code does not give enough details about your problem
odo22
odo22 2016년 7월 21일
편집: odo22 2016년 7월 21일
This is literally the only piece of code I'm using...I have a second part which I omitted for clarity but I don't think it's the source of my problem:
xlim([450, 800]);
ylim([0.0,0.35]);
set(gca,'FontSize',15)
set(findall(gcf,'type','text'),'FontSize',50)
ax = gca;
set(gca,'XMinorTick','on','YMinorTick','off')
ax.FontSize = 50;
ax.YTick = [0.1 0.2 0.3 ];
ax.XTick = [ 500 600 700 800];
ax.Box = 'on';
ax.LineWidth = 7;
hold off
Even if I delete this second part from my script, it still plot the straight lines alongside my data :(

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2016년 7월 21일
편집: Stephen23 2016년 7월 21일
It is your data. They are not in sequence along the X axis, and so this is how the Y values are plotted.
Something like this:
>> X = [0:0.01:3*pi/2,0]; % the RHS zero is out of sequence!
>> Y = sin(X);
>> plot(X,Y)
  댓글 수: 1
odo22
odo22 2016년 7월 21일
Thank you so much!
My data was in the correct order but for some reason the matrix was filled with zeros at the bottom (i.e. the bottom rows)...
I got rid of them and now it works!
Thanks once more!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by