set of equations printing using sprintf command
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want to print the following set of equations using sprintf command.
p=1,2,...,8
c=1,2,..,4
t = 1,2,...,12,
m= 1,2.
see the attachment file for the equation.
Note: D(p,c,t) is a number (input data).
3 commentaires
OCDER
le 12 Sep 2017
I agree, this eqn in the txt file is hard to understand:
?_(m?D(c))??tc?_pmct = D_?(pct@) - ?tar?_?(pct@ ) for all p,c,t.
Also, the range of values of p, c, t, m are all different. Do you want (8x4x12x2) combinations of an equation?
Stephen23
le 12 Sep 2017
Modifié(e) : Stephen23
le 12 Sep 2017
@Mechanical Engineering: what you seem to be trying to do is access a whole lot of variable names dynamically. This is a terrible way to write code: slow, pointlessly complex, buggy, hard to follow, hard to debug, and insecure: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
As a much better alternative you should really learn about indexing, which is simple, neat, easy to debug, and very efficient.
If you want to use MATLAB why are you mucking about with strings? Encoding data into strings and trying to parse them is an awfully complex and inefficient way to write code. Instead, why not learn how to use MATLAB, and use numeric arrays and indexing?
I would recommend that you actually tell us what your task is, rather than wasting time asking us how to do awkward and ugly code like that. Your question seems to be an example of the X-Y problem:
and you would get much better results and we would all save a lot of time if you simply explained what your goal is.
Réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Identification dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!