The following error occurred converting from sym to double: Unable to convert expression containing symbolic variables into double array Apply' subs' function first to substitute values for variables.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
When I try the loop for ii (see attached mix file) I get this error:
The following error occurred converting from sym to double: Unable to convert expression containing symbolic variables into double array Apply'subs' function first to substitute values for variables.
It has solution because I tried writing each ii and the respective equations. But I need the loop (obviously) because I want to introduce several values of ii and unknows to the system.
PD: Not so important but, as you can see, inside of the equation eqll, eqll. eqlll ... are the unknowns CO, C1 .... DO, D1, ... which are inside of a series (but I) couldnt find a way, so I wrote the elements of the serie) Is there any way to optimize that?
2 Commenti
Risposte (1)
Walter Roberson
il 10 Dic 2020
eqI = zeros (1,points, 'sym');
eqII = zeros (1,points, 'sym');
eqIII = zeros (1,points, 'sym');
4 Commenti
Walter Roberson
il 11 Dic 2020
As the question is not about how to write the algorithm at all, and is instead about how to write the algorithm "more nicely", then you can
eqI(ii) = (1/h)*C0 + (2/h)*sum( C .*cos(Npih.*(z(1,ii)+h)), 2)-d;
eqI_old(ii) = (1/h)*C0 + (2/h)*(C1*cos(1*pi*(z(1,ii)+h)/h)+...+C8*cos(8*pi*(z(1,ii)+h)/h))-d; %all of the old code
and compare compare the two, such as checking whether their difference is 0. If the two are different, then start debugging.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!