How to set an array in matlab?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I ma trying to plot a graph Re as a function of k. But before that, I need to input A,B and v to calculate a,b,c,d,alpha and beta.
Below is my code:
clear all
A1=input('What is the value of A ','s');
B1=input('What is the value of B ','s');
V1=input('What is the value of V ','s');
K1=input('What is the value of K ','s');
A=str2num(A1);
B=str2num(B1);
K=str2num(K1);
V=str2num(V1);
a=B; %%%formula for a
b=(A+sqrt(A.^2 - 4*(B.^2)))/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for b
c= -2*B; %%%formula for c
d=-2*A/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for d
array(K);
alpha=(a+d-K.^2).^2 - (K.^2)*(V.^2)-4*(a*d - b*c - d*(K.^2))
beta=2*K*V*(K.^2 - a + d)
re=1/2 *(a+d-K.^2+ sqrt((1/2 *((sqrt((alpha).^2 + (beta).^2))+ alpha))))
%A plot Re as a function of k
K=(0:0.01:1);
y=re;
figure;
plot(K,y,'r');
title('Re as a function of k', 'fontsize', 10);
xlabel('K');
ylabel('Re');
0 commentaires
Réponses (1)
A Jenkins
le 17 Fév 2014
I'm not really sure what your question is. Are you trying to do this?
clear all
A1=input('What is the value of A ','s');
B1=input('What is the value of B ','s');
V1=input('What is the value of V ','s');
K1=input('What is the value of K ','s');
A=str2num(A1);
B=str2num(B1);
K=str2num(K1);
V=str2num(V1);
a=B; %%%formula for a
b=(A+sqrt(A.^2 - 4*(B.^2)))/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for b
c= -2*B; %%%formula for c
d=-2*A/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for d
%array(K);
K=(0:0.01:1);
alpha=(a+d-K.^2).^2 - (K.^2)*(V.^2)-4*(a*d - b*c - d*(K.^2))
beta=2.*K.*V.*(K.^2 - a + d)
re=1/2 *(a+d-K.^2+ sqrt((1/2 *((sqrt((alpha).^2 + (beta).^2))+ alpha))))
%A plot Re as a function of k
y=re;
figure;
plot(K,y,'r');
title('Re as a function of k', 'fontsize', 10);
xlabel('K');
ylabel('Re');
2 commentaires
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!