How can I do two variable for loop using vector elements with their index positions
Show older comments
Hi, Im new using matlab and i want to use a "for loop" to solve an equation but i need to use elements from vector to solve it and get the diferent answers. i have two vectors with the same lenght i want know the answer for any position equals to another. for example i need the element of the position 1 from vector Theta_1 and vector X, to know the value of m1. but using this kind of double loop i have a problem i dont now hot to access to an element from the vector, i guees that using an "if" for separate the relevant information [Theta_1pos(i)==Xpos(i)] from the useless. I have two mainly questions, first How can i use the element from a index postion to calculate the answer that i need? my second question is How can i store all the answers in a vector without using the function "disp()".?
%%Vectores iniciales
X=0.050:0.050:0.350;
T1=[45.5 38.0 32.4 28.7 26.2 24.9 24.1];
%%Constantes[1]
Tinf=18.8;
Tb=55.7;
Theta_b=Tb-Tinf;
%%Vector theta
Theta_1=T1-Tinf;
for k= element pos(Theta_1): lenght(Theta_1)
for xpos one to lenght
syms m
eqn = (cosh(m*(L-x))/cosh(m*L))==(k);
solm = solve(eqn,m)
if (kpostion==xposition)
disp(solm)
end
end
end
Answers (0)
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!