Clear Filters
Clear Filters

THE CODE BELOW GIVES MULTIPLE PLOTS FOR A PLOT COMMAND, NEED A SINGLE PLOT

3 views (last 30 days)
I HAD EXPECTED THE CODE BELOW TO GENERATE A SINGLE PLOT BUT IT GENERATES THE NUMBER OF PLOTS EQUAL TO THE LENGTH OF THE INPUT VECTOR (t). Don't know what is wrong. % Function that calculates the ML by prompting the user for inputs function output =Gen_ML(t) %Accept the initial time value firstIndex =input('Enter first index:'); %Accept the final time value lastIndex = input('Enter last index:'); %Accept the value of first constant alpha a=input('Enter alpha vaule'); %Accept the value of the second constant beta b=input('Enter beta value'); %Accept the value of constant lambda one l1=input('Enter lambda one'); %Accept the value of constant lambda two l2=input('Enter lambda two'); t=firstIndex:lastIndex; for n=firstIndex:lastIndex output(n,:) = 0.0635*(t.^-0.6)* sum((l1*t.^a*n)/(gamma(n*a+b))) +0.0268*(t.^-0.6)* sum((l2*t.^a*n)/(gamma(n*a+b))) ; end

Accepted Answer

pfb
pfb on 24 Dec 2013
I'm not entirely sure I understand your question. Your code is inline and a bit difficult to decipher. From the look of it, output is a matrix with as many rows as the number of indices, and as many columns as the size of the t vector (again the number of indices). Assuming this is really what you want to do, when you plot the matrix you get one plot for each column, as specified in the help for the command plot (type help plot in the command window). If you want to plot, say, the 3rd column only, you should type
plot(output(:,3));
Francesco

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!