Thread Subject: pseudo fprintf user defined function

Subject: pseudo fprintf user defined function

From: Wai Kwan

Date: 9 Nov, 2009 03:39:02

Message: 1 of 5

Hello all,

I feel bad for asking a silly question here but I am still a freshie on MATLAB.
I am having an assignment from university and apparently I was asked to prepare a new function which is similar to fprintf.

The function should be able to act like fprintf,just for the string printing part only.
The emulated function should be able to behave differently if you supply return variable
(ret = fprintf('hi') % prints `hi' and assign 2 to variable ret) and if you do not supply such return variable (fprintf('hi') % just prints `hi').

I have been stuck for days.Seriously need all of your help A.S.A.P.
Thanks in advance.

Warmly,
WaiKwan

Subject: pseudo fprintf user defined function

From: TideMan

Date: 9 Nov, 2009 07:31:30

Message: 2 of 5

On Nov 9, 4:39 pm, "Wai Kwan " <waikwan_...@hotmail.com> wrote:
> Hello all,
>
> I feel bad for asking a silly question here but I am still a freshie on MATLAB.
> I am having an assignment from university and apparently I was asked to prepare a new function which is similar to fprintf.
>
> The function should be able to act like fprintf,just for the string printing part only.
> The emulated function should be able to behave differently if you supply return variable
> (ret = fprintf('hi') % prints `hi' and assign 2 to variable ret) and if you do not supply such return variable (fprintf('hi') % just prints `hi').
>
> I have been stuck for days.Seriously need all of your help A.S.A.P.
> Thanks in advance.
>
> Warmly,
> WaiKwan

So, what have you tried so far?
Or do you expect us to do your homework for you?
And if we do this, will you submit it and claim it as your own work?
Honestly, I really want to help you, but I'm afraid that if I do so,
that will make you a liar and a cheat.
Perhaps the best thing would be if you posted your professor's email,
then we can submit our solution to your homework directly to him
pointing out the dilemma that we are facing.


Subject: pseudo fprintf user defined function

From: Wai Kwan

Date: 9 Nov, 2009 11:34:02

Message: 3 of 5

TideMan <mulgor@gmail.com> wrote in message <172f7d91-1f1b-4fcb-bea3-a4cbf034d92f@g1g2000pra.googlegroups.com>...
> On Nov 9, 4:39?pm, "Wai Kwan " <waikwan_...@hotmail.com> wrote:
> > Hello all,
> >
> > I feel bad for asking a silly question here but I am still a freshie on MATLAB.
> > I am having an assignment from university and apparently I was asked to prepare a new function which is similar to fprintf.
> >
> > The function should be able to act like fprintf,just for the string printing part only.
> > The emulated function should be able to behave differently if you supply return variable
> > (ret = fprintf('hi') % prints `hi' and assign 2 to variable ret) and if you do not supply such return variable (fprintf('hi') % just prints `hi').
> >
> > I have been stuck for days.Seriously need all of your help A.S.A.P.
> > Thanks in advance.
> >
> > Warmly,
> > WaiKwan
>
> So, what have you tried so far?
> Or do you expect us to do your homework for you?
> And if we do this, will you submit it and claim it as your own work?
> Honestly, I really want to help you, but I'm afraid that if I do so,
> that will make you a liar and a cheat.
> Perhaps the best thing would be if you posted your professor's email,
> then we can submit our solution to your homework directly to him
> pointing out the dilemma that we are facing.
>
>
Hi tideman,
For your first question,I have tried using "char"function and "sprintf"function to print out this string.And I failed to suppress the length of the string as I wish.
2nd question,no i want to do my work my own.
3rd,I am seeking advice here.If I could figure that myself,do I need to post my trouble here?
And thanks for reading my post and take your time replying this.
I sincerely thank you if you wish to care.I also welcome you if you feel like lecturing me.
=)

WaiKwan

Subject: pseudo fprintf user defined function

From: Steven Lord

Date: 9 Nov, 2009 14:37:08

Message: 4 of 5


"Wai Kwan " <waikwan_lim@hotmail.com> wrote in message
news:hd82sm$k7t$1@fred.mathworks.com...
> Hello all,
>
> I feel bad for asking a silly question here but I am still a freshie on
> MATLAB.
> I am having an assignment from university and apparently I was asked to
> prepare a new function which is similar to fprintf.
>
> The function should be able to act like fprintf,just for the string
> printing part only.
> The emulated function should be able to behave differently if you supply
> return variable
> (ret = fprintf('hi') % prints `hi' and assign 2 to variable ret) and if
> you do not supply such return variable (fprintf('hi') % just prints `hi').
>
> I have been stuck for days.Seriously need all of your help A.S.A.P.
> Thanks in advance.

We'd like to help you, but you didn't actually ask a question in this
posting ... if you ask a question about a specific section of the code
you've written and show us that code, it's much more likely that we'll
actually be able to help you.

As a guess, I suspect you're not sure how to differentiate between the
output argument/no output argument cases. If so, look at HELP NARGOUT.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: pseudo fprintf user defined function

From: Wai Kwan

Date: 10 Nov, 2009 03:14:01

Message: 5 of 5

"Steven Lord" <slord@mathworks.com> wrote in message <hd99cp$64$1@fred.mathworks.com>...
>
> "Wai Kwan " <waikwan_lim@hotmail.com> wrote in message
> news:hd82sm$k7t$1@fred.mathworks.com...
> > Hello all,
> >
> > I feel bad for asking a silly question here but I am still a freshie on
> > MATLAB.
> > I am having an assignment from university and apparently I was asked to
> > prepare a new function which is similar to fprintf.
> >
> > The function should be able to act like fprintf,just for the string
> > printing part only.
> > The emulated function should be able to behave differently if you supply
> > return variable
> > (ret = fprintf('hi') % prints `hi' and assign 2 to variable ret) and if
> > you do not supply such return variable (fprintf('hi') % just prints `hi').
> >
> > I have been stuck for days.Seriously need all of your help A.S.A.P.
> > Thanks in advance.
>
> We'd like to help you, but you didn't actually ask a question in this
> posting ... if you ask a question about a specific section of the code
> you've written and show us that code, it's much more likely that we'll
> actually be able to help you.
>
> As a guess, I suspect you're not sure how to differentiate between the
> output argument/no output argument cases. If so, look at HELP NARGOUT.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
Hi Steven,

Thanks for the reminder on nargout function part. Using this method,I did solve my problem.
Thanks again for the guidance. =)

WaiKwan

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com