set of equations printing using sprintf command

1 次查看(过去 30 天)
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 个评论
OCDER
OCDER 2017-9-12
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
Stephen23 2017-9-12
编辑:Stephen23 2017-9-12
@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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by