Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Substitution of Operators

Subject: Substitution of Operators

From: Omid

Date: 18 Jan, 2013 12:27:08

Message: 1 of 3

Hello everyone,

I need to substitute one operator in my program with another operator (*. with *)
but i do not know how it is possible.
I would appreciate if anyone knows a function which do that.

Thank you in advance

Subject: Substitution of Operators

From: Steven_Lord

Date: 18 Jan, 2013 15:12:05

Message: 2 of 3



"Omid " <omid.yousefian88@gmail.com> wrote in message
news:kdbf2r$lfc$1@newscl01ah.mathworks.com...
> Hello everyone,
>
> I need to substitute one operator in my program with another operator (*.
> with *)
> but i do not know how it is possible.
> I would appreciate if anyone knows a function which do that.

Two possible approaches:

Open the file in the MATLAB Editor.
Use Find/Replace to perform the replacement.

or

Read the function file in as a text file.
Perform the replacement.
Write the modified text into a new function file.

The file I/O and string processing functions listed in the output of these
two commands will be useful to you for the second approach:

help iofun
help strfun

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Substitution of Operators

From: John D'Errico

Date: 18 Jan, 2013 15:17:08

Message: 3 of 3

"Omid " <omid.yousefian88@gmail.com> wrote in message <kdbf2r$lfc$1@newscl01ah.mathworks.com>...
> Hello everyone,
>
> I need to substitute one operator in my program with another operator (*. with *)
> but i do not know how it is possible.
> I would appreciate if anyone knows a function which do that.
>
> Thank you in advance

Use the editor? Find and replace should suffice.
Check each occurrence to make sure that .* was
not the real intended operator, or you will create
bugs.

By the way, *. is not a valid matlab operator, but
.* is.

If you really insist on doing this programmatically,
I'd suggest that would be a foolish task. It is too
risky that you create bugs by letting a program
change all occurrences. Don't let your computer do
the thinking or you. Computers are a bit dumber
than people think they are.

John

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us