How to change mathematical symbols of division (/ to ./) and multiplication(* to .*) in a very long formula obtained by symbolic tool.

조회 수: 2 (최근 30일)
I am using symbolic toolbox in order to write a formula and differentiation etc. After I have to use my final formula in a function. But in obtained formula by symbolic toolbox, symbol of division and multiplication are / and * respectively. When I put the values of a variable in vector or matrix form, It gives the error. So I have to change the symbols manually for example / (division) to ./ and * (multiply) to .*
Is there any alternate way to solve this problem. Thanks in advance.

채택된 답변

Mischa Kim
Mischa Kim 2014년 3월 27일
Mahak, copy-paste the formula into a script/function editor and use CTRL+F to replace the strings.
  댓글 수: 1
Mahak SINGH CHAUHAN
Mahak SINGH CHAUHAN 2014년 3월 27일
Thank You very much Mischa, I also did same just after putting question here. Thanks again for your reply.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 3월 27일
편집: Joseph Cheng 2014년 3월 27일
to do this you can do something like this.
textEquation=char(symsEquation);
division = [0 strfind(textEquation,'/')];
elbyelDivEquation=[];
for i =1:length(division)-1
elbyelDivEquation = [elbyelDivEquation textEquation(division(i)+1:division(i+1)-1) './'];
end
elbyelDivEquation=syms(elbyelDivEquation);
I did the / substitution quickly so didn't verify if it actually does capture whats between the / and then inserts the other portions. but that should do the trick.
  댓글 수: 2
Mahak SINGH CHAUHAN
Mahak SINGH CHAUHAN 2014년 3월 27일
Thank You Joseph.. It may also be another way to change.
Joseph Cheng
Joseph Cheng 2014년 3월 27일
if this is a one off then Mischa Kim solution would be easier. However if this is going to happen routinely (say in a program or multiple runs in a script) you may want to automate it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by