Need to access the structure values in numerical form and store it in an array each time the loop runs
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all,
I am trying to access the structure values from the followign code and want to store it in the form of an array each time the loop runs. I have tried using stryct2cell and cell2mat but they give certain errors. I need the numerical values of x and y by solving the two equations.
Since I am very new to MATLAB programming, I do not much of an idea what does the structure hold in this case and how can we access the numerical values. Kindly help me.
for i = 1:127
syms x y
sol = solve([(1-x)*(1-exp(-y))+ A32T22_array(i)*(1-x)*exp(-y)+ T2T12_array(i) + R2_array(i) == 1, x + R1_array(i)*(1-x)*exp(-y) == R2_array(i), x>0, y>0], [x,y]);
R12T12_array(i) = solxy(1,1);
ad_array(i) = solxy(2,1);
end
댓글 수: 0
채택된 답변
darova
2021년 8월 2일
Make some modifications
An example
syms x y
sol = solve([5*x-y y-1])
댓글 수: 3
darova
2021년 8월 4일
Looks like you have several roots
just type in the other line
sol.x
And see how many roots you have. Maybe you need something lke this:
R12T12_array = nan(127,5); % assuming max number of roots: 5
for i = 1:127
% code
n = numel(sol.x);
R12T12_array(i,1:n) = sol.x; % write roots
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!