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

2 次查看(过去 30 天)
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

采纳的回答

pfb
pfb 2013-12-24
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by