I=[-40 -30 -20 -10 0 10 20 30 40];
w=[0.035 0.5 1 1.25 1.5];
h=1.57;
I_len=length(I);
w_len=length(w);
for b=1:w_len
d=w(b);
for c = 1:I_len
a = I(c);
T=215.3*a^2*d^-1.5*h^-1;
end
end
This is my code.
how do I tabulate the results of a,d,h,T and plot the graph for the same?

 채택된 답변

KSSV
KSSV 2019년 6월 18일

0 개 추천

I=[-40 -30 -20 -10 0 10 20 30 40];
w=[0.035 0.5 1 1.25 1.5];
h=1.57;
I_len=length(I);
w_len=length(w);
T = zeros(w_len,I_len) ;
for b=1:w_len
d=w(b);
for c = 1:I_len
a = I(c);
T(b,c)=215.3*a^2*d^-1.5*h^-1;
end
end
[X,Y] = meshgrid(I,w) ;
surf(X,Y,T)

댓글 수: 4

Sachin Shridhar Bhat
Sachin Shridhar Bhat 2019년 6월 18일
Can you explain me what did you do in the above code?
because I had tried with mesh grid and had used sliceomatic and I got an error with it.
so can you tell me?
KSSV
KSSV 2019년 6월 18일
It is self explanatory.......variables I, w are introduced in meshgrid to make it a matrix. T is initialized. In fact, you need not to use meshgrid, with T as matrix itself, it can be plotted. Simply try:
surf(I,w,T)
Sachin Shridhar Bhat
Sachin Shridhar Bhat 2019년 6월 18일
Okay thank you
KSSV
KSSV 2019년 6월 18일
Thanks is accepting and/or voting the answer. :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Shubham Sangle
Shubham Sangle 2019년 6월 18일

0 개 추천

Your question is not clear.
1:Graph between what parameters you want to plot?
2:In your For loop you are assigning every element of array to variable d and b. You are neither using them anywhere nor storing them. what you want to do with those variable?

댓글 수: 1

Sachin Shridhar Bhat
Sachin Shridhar Bhat 2019년 6월 18일
1 - Graph between a,d,h,T
2- In for loop I am assigning each variable of w to d and I to a . And of course I am using those values to calculate the final T value in the equation below.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2019a

태그

질문:

2019년 6월 18일

댓글:

2019년 6월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by