조회 수: 2(최근 30일)
Ertan Aras 6 May 2019
댓글: Star Strider 6 May 2019
Hello friends,I have parametric equation about 5 paper,I want to add dot for every * and / signs to use linspace.How can I do automatically
Rik 6 May 2019

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

### 채택된 답변

Star Strider 6 May 2019
편집: Star Strider 6 May 2019
The only change you temporatily need to make is to create your function as a character vector by putting single quotes (') around it first, then removing them from the vectorize output.
Example —
f = exp(-0.1*t) * sin(2*pi*t);
fv = vectorize('exp(-0.1*t) * sin(2*pi*t)')
producing:
fv =
'exp(-0.1.*t) .* sin(2.*pi.*t)'
You then have to manually edit your expression to put it back as a valid expression. That simply means removing the single quotes:
f = exp(-0.1.*t) .* sin(2.*pi.*t)
EDIT — Corrected typographical errors.
##### 댓글 수: 4표시숨기기 이전 댓글 수: 3
Star Strider 6 May 2019
As always, my pleasure!

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

### 추가 답변(1개)

gonzalo Mier 6 May 2019
You have two possibilities here:
1. In the text file, you replace * by .* and / by ./ in all the document (there is an option in the replace to replace all).
2. If you have it like a function and want to do it by programming, you can overload the funtion mtimes and mrdivide by times and rdivide as:
function c = mtimes(a,b), c = times(a,b); end
function c = mrdivide(a,b), c = rdivide(a,b); end
By preference, always do the first method, as overloading operators is not a good practice unless you try to ofuscate your code, but I have found some moments where it's the only way

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

### 태그

아직 태그를 입력하지 않았습니다.

### Community Treasure Hunt

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

Start Hunting!

Translated by