Filter löschen
Filter löschen

How to print cell contents into m-file?

2 Ansichten (letzte 30 Tage)
Akbar
Akbar am 8 Jun. 2018
Beantwortet: Stephen23 am 8 Jun. 2018
I Need to Combine These two variables and print in m-file. inputs and signs length may vary. signs can only contain multiplication and/or Division.
inputs = {'x' 'y' 'z' 'k'};
signs = '**/';
How to write the following line in m-file?
out = x*y*z/k;

Akzeptierte Antwort

Stephen23
Stephen23 am 8 Jun. 2018
>> inputs = {'x' 'y' 'z' 'k'};
>> signs = '**/';
>> C = inputs;
>> C(2,1:end-1) = num2cell(signs);
>> fprintf('out = %s;\n',[C{1:end-1}])
out = x*y*z/k;

Weitere Antworten (1)

Jan
Jan am 8 Jun. 2018
inputs = {'x' 'y' 'z' 'k'};
signs = '**/';
Result = inputs{1};
for k = 1:numel(signs)
Result = [Result, signs(k), inputs{k+1}];
end
  1 Kommentar
Akbar
Akbar am 8 Jun. 2018
How to print it to the file? And without square brackets.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by