back again, stuck again!
hey guys, im working a problem where i have to make a for loop to generate 6 sub plots of a function for array [0,2] and a = [.05, .1, .2, .4, .6, 1.0]. i also am trying to plot all the lines on the same graph.
the function is 1./sqrt(((1-x.^n).^n)+(4*a.^n.*x.^n))
for some reason im only getting two graphs when i should be getting 6, as well as only two results on the combination graph. i dont know if anyone is even up but if you are, take a crack at it. here is my code:
clear all
clc
close all
A = [0.05,0.1,0.2,0.4,0.6,1.0];% vector of zeta values
n = 2; % dealing with one power
x = linspace(0,2); % An array of omega
for i = 1:6
a = A(i); % selecting a constant from the vector A in each loop
f = @(x,a) 1./sqrt(((1-x.^n).^n)+(4*a.^n.*x.^n));% creates a function with a handle
figure(1)
subplot(2,2,i) % 2 by 2 subplot 4 plots for the ith plot
plot(x,f(x,a))
xlabel('x')
ylabel() % changing the ylabel on each iteration
title()
figure(2)% Plots all curves on the same plot
color = ;
hold on
plot(x,f(x,a),color(i))
xlabel('x')
ylabel('f(x,a)')
title()
text(0,f(0,a),)
legval(i,:) = char(abs());% creates a legend string row vector for
% the ith row.The strings change in size after each iteration that is
% why ':' is used.
legend(legval) % creates the legend using legval
end
the function is 1./sqrt(((1-x.^n).^n)+(4*a.^n.*x.^n))
for some reason im only getting two graphs when i should be getting 6, as well as only two results on the combination graph. i dont know if anyone is even up but if you are, take a crack at it. here is my code:
clear all
clc
close all
A = [0.05,0.1,0.2,0.4,0.6,1.0];% vector of zeta values
n = 2; % dealing with one power
x = linspace(0,2); % An array of omega
for i = 1:6
a = A(i); % selecting a constant from the vector A in each loop
f = @(x,a) 1./sqrt(((1-x.^n).^n)+(4*a.^n.*x.^n));% creates a function with a handle
figure(1)
subplot(2,2,i) % 2 by 2 subplot 4 plots for the ith plot
plot(x,f(x,a))
xlabel('x')
ylabel() % changing the ylabel on each iteration
title()
figure(2)% Plots all curves on the same plot
color = ;
hold on
plot(x,f(x,a),color(i))
xlabel('x')
ylabel('f(x,a)')
title()
text(0,f(0,a),)
legval(i,:) = char(abs());% creates a legend string row vector for
% the ith row.The strings change in size after each iteration that is
% why ':' is used.
legend(legval) % creates the legend using legval
end
0
Comments
Before outputting each graph just have it print the value of i to see if it's finishing the loop or breaking early.
EDIT: MathWorks has this to say about it:
Try creating a figure handle instead of using an integer designator.