How to set an array in matlab?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
A Jenkins
2014년 2월 17일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!