Graphs not plotting correctly.

32 views (last 30 days)
First of all, I went ahead and reworked the messy goto-crap (or I am trying at least right now).
However, now that I am working on those, I get two problems, both of them I have no clue why they even happen.
Right now, when I plot all graphs using the new functions, as long as I don't define an axis before the function actually plots them, the graphs are cut short randomly and at different points:First of all, I went ahead and reworked the messy goto-crap (or I am trying at least right now).
However, now that I am working on those, I get two problems, both of them I have no clue why they even happen.
Right now, when I plot all graphs using the new functions, as long as I don't define an axis before the function actually plots them, the graphs are cut short randomly and at different points:
This would also happen if I define my axis before the plot of the graph function. It just won't be noticeable until I move the plot around.
Why do these graphs not go all the way? And why do they stop at different points?
As I understand it, the axis limits don't result in the graphs being plotted differently. And, as I remember from other codes I've written, that's not the case.
Also, am I right to assume that I should open a new question every time, instead of asking as follow-ups on my first one?
Thank you
ttest is the file with the normal script.
%%% Normal Script
%% First section is just vector definition
InputCheckFinished=1;
for InputCheck=1:1:InputCheckFinished;
answer = inputdlg('How many X are plotted?:',...
'Sample', [1 50]);
NofRepeatsX= str2double(answer{1});
answer = inputdlg('How many Y are plotted?:',...
'Sample', [1 50]);
NofRepeatsY= str2double(answer{1});
end
for j=1:1:NofRepeatsX
answer = inputdlg('Enter x-Vector with spaces line by line, 1 iteration=1 vector later on:',...
'Sample', [1 100]);
x_Vector= str2num(answer{1});
matx(j,:)=x_Vector
j=j+1;
end
for j=1:1:NofRepeatsY
answer = inputdlg('Enter y-Vector with spaces line by line, 1 iteration=1 vector later on:',...
'Sample', [1 100]);
y_Vector= str2num(answer{1});
maty(j,:)=y_Vector
j=j+1;
end
clear answer
%% second section is calling the fit and plot functions/defining axis
close all
[NumRows,NumCols]=size(maty);
clear NumCols
hold on
fits=LPfitfun(matx,maty,NumRows)
hold on
axis([-10 10 -10 10])
plotfunction_beta
axis([-10 10 -10 10])
%hold on
%% third section: the fit function (not the same script as section 1/2)
function [fits] = LPfitfun(matx,maty,NumRows)
%LPfitfun Summary of this function goes here
% compute a LPfit for inputs matx,maty,fittype poly1
for k=1:1:NumRows
hold on
fits{k}=fit(matx(k,:)',maty(k,:)','poly1')
hold on
end
end
%% fourth section: the plot function that is not a function. I cant get the actual function to work (see last section) (not the same script as section 1/2)
fits=LPfitfun(matx,maty,NumRows) %fits is the name of the cell in which all fits are stored. the string
%LPfitfun(matx,maty,Numrows) takes these
hold on
for k=1:1:NumRows
hold on
axis()
plot(fits{1,k},'')
hold on
plot(matx(k,:),maty(k,:),'o')
hold on
end
disp('DONEBeta')
%% fifth section: the actual plot function that is not working
function[LPplotfun]=LPplotfun(matx,maty,fits,NumRows)
%LPplotfun plots all LPfitset up by LPfitfun
hold on
for k=1:1:NumRows
hold on
plot(fits(1,1),'')
hold on
plot(matx(k,:),maty(k,:),'o')
hold on
pause(3)
hold off
end
hold on
disp('Doneplotfun')
end
%% Error message when trying to plot using LPplotfun:
Not enough input arguments.
Error in LPplotfun (line 4)
for k=1:1:NumRows
Error in ttest (line 190)
LPplotfun
% I know this is a bit of a problem- and code-dump. I am not seeing the problem right now.
  1 Comment
TJ Plummer
TJ Plummer on 17 Mar 2020
Hello,
How are calling LPplotfun ?
Seems like NumRows is not defined or passed into LPplotfun.

Sign in to comment.

Accepted Answer

TJ Plummer
TJ Plummer on 17 Mar 2020
Replace you plotfunction_beta with your function:
LPplotfun(matx,maty,fits,NumRows)
Also, I never have returned the name of a function in function return like that. It is okay if your function is defined as:
function LPplotfun(matx,maty,fits,NumRows)
end
or
function[]=LPplotfun(matx,maty,fits,NumRows)

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!