Clear Filters
Clear Filters

How to convert a 25 X 25 sym to 25 x 25 double?

1 view (last 30 days)
Greeting, i have been finding it difficult to convert a Matrix naming "AA" (25 x 25 Sym) containg various symbolic expression of two polynomials, into a 25 X 25 double matirx ". The objective is to double integrate each element of the Matrix "AA" with respect to certain variable under definite limits.
The screen shot of the code for the same has been attached for reference. Requesting for necessary assistance and gudance. urgently required. Thanks in advance
Note:- The information regarding the variable shown in code :-
G(i,:) , P(j,:), H(k,:) & Q(m,:) are depicted for the each rows of 5 x 25 sym.
  2 Comments
Richard Johnson
Richard Johnson on 24 May 2023
Also, the function handle ht3 is taking up only one element as its handle and integrating it. the result is been placed over all the elements of T.
Dyuman Joshi
Dyuman Joshi on 24 May 2023
Why not let them be symbolic array and use int twice? And then you can use double() on the final output.
Also, it is better to copy-paste your code or attach it code using the paperclip button.

Sign in to comment.

Answers (1)

Shree Charan
Shree Charan on 31 May 2023
Edited: Shree Charan on 31 May 2023
Hi Richard,
I’m assuming that the difficulty you’re facing is that the function handle ‘ht3’ is taking up only one element as its handle and integrating it. the result is being placed over all the elements of ‘T’.
It seems like in your code snippet, the loop variables ‘I’, ‘j’, ‘k’, and ‘m’ are set to a constant value of 5, which means that the nested for loops are not iterating through multiple values of these variables. As a result, ‘AA’ will be computed only once during the first iteration of the loop, and ‘ht3’ will be a constant function handle for all the subsequent iterations. Therefore, the numerical integration of ‘ht3’ over the specified ranges will produce the same result every time, and that value will be assigned to all the elements of matrix ‘T’, resulting in a constant value repeated over all elements.
This might provide a fix for the same.
T = zeros(25,25);
rr=1;
for i = 1:5
for j = 1:5
ss = 1;
for k = 1:5
for m = 1:5
AA = matlabFunction(Q(i,:)'.*P(j,:).*H(k,:)'.*Q(m,:).*ht1);
ht3 = matlabFunction(AA);
T(rr,ss) = integral2(ht3, 0.01, pi/2, 0.01, 2*pi);
ss = ss+1;
end
end
rr = rr+1;
end
end

Community Treasure Hunt

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

Start Hunting!