f



MatLab help #27

Hi,

I have a copy of a program that reads two small pngs and sends them
out over two serial ports. It's old and its evidently a bad edit, so
could someone please tell me what's the matter with this crazy thing?!
It seems to be in the variables and then it blows its cool in the
reshape command. I have not programmed anything in MatLab since
forever, but i need this to work for a project I am doing. Best copy I
have, evidently I deleted the working copy and for the life of me, I
can't fix it. Any good people out there that can help edit this crazy
thing back to health?

See code below, relatively straightforward, but its not compiling...I
dunno. My feeble attempts to fix it after all these years is...um...
feeble... ;-) I barely remember how to load up a script, much less.
BUT I gotta have it, any takers?

Best Regards,

Jeff

-------------------------------------------------------------

%Read two image files
A=imread('Bright1.png','png');
B=imread('Bright2.png','png');
A=rgb2gray(A);
B=rgb2gray(B);
[a1 b1]=size(A);
[a2 b2]=size(B);

count1=a1*b1;
count2=a2*b2;
count=min(count1,count2);

C1=reshape(A1,1,count1);
C2=reshape(A2,1,count2);

%Create serial port objects to open the serial ports
s1=serial('com6','baudrate',230400,'outputbuffersize',2*count);
fopen(s1);
s2=serial('com5','baudrate',230400,'inputbuffersize',2*count);
fopen(s2);

%Serial Port Write Operation
tic
     fwrite(s1,C1(1,1:count1),'uint8');
     fwrite(s2,C2(1,1:count2),'uint8');
toc
%Display the images
imshow(A1);
imshow(A2);

%Close the serial port and delete the serial port objects
fclose(s1);
fclose(s2);
delete(s1);
delete(s2);
0
4/30/2012 1:49:09 AM
comp.soft-sys.matlab 211264 articles. 26 followers. lunamoonmoon (257) is leader. Post Follow

6 Replies
834 Views

Similar Articles

[PageSpeed] 3

I think these
C1=reshape(A1,1,count1);
C2=reshape(A2,1,count2);

should actually be these:

C1=reshape(A,1,count1);
C2=reshape(B,1,count2);

And C1 and C2 are now 1D arrays so this:
     fwrite(s1,C1(1,1:count1),'uint8');
     fwrite(s2,C2(1,1:count2),'uint8');
should be this:
     fwrite(s1,C1,'uint8');
     fwrite(s2,C2,'uint8');
since they're not 2D arrays and since you're writing the whole thing
out.

If you want, you can replace this:
[a1 b1]=size(A);
[a2 b2]=size(B);

count1=a1*b1;
count2=a2*b2;

with this:
count1 = numel(A); % Number of elements in A.
count2 = numel(B); % Number of elements in B.

Try those suggestions and see how it goes.
0
imageanalyst (7621)
4/30/2012 3:33:44 AM
On Apr 29, 11:33=A0pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> I think these
> C1=3Dreshape(A1,1,count1);
> C2=3Dreshape(A2,1,count2);
>
> should actually be these:
>
> C1=3Dreshape(A,1,count1);
> C2=3Dreshape(B,1,count2);
>
> And C1 and C2 are now 1D arrays so this:
> =A0 =A0 =A0fwrite(s1,C1(1,1:count1),'uint8');
> =A0 =A0 =A0fwrite(s2,C2(1,1:count2),'uint8');
> should be this:
> =A0 =A0 =A0fwrite(s1,C1,'uint8');
> =A0 =A0 =A0fwrite(s2,C2,'uint8');
> since they're not 2D arrays and since you're writing the whole thing
> out.
>
> If you want, you can replace this:
> [a1 b1]=3Dsize(A);
> [a2 b2]=3Dsize(B);
>
> count1=3Da1*b1;
> count2=3Da2*b2;
>
> with this:
> count1 =3D numel(A); % Number of elements in A.
> count2 =3D numel(B); % Number of elements in B.
>
> Try those suggestions and see how it goes.

>>Hi, and thanks! yes, that fixed the s/w it seems, however, I still get :

??? Error using =3D=3D> serial.fwrite at 199
The number of bytes written must be less than or equal to
OutputBufferSize-BytesToOutput.

Error in =3D=3D> PicTX at 35
     fwrite(s2,C2,'uint8');

Code looks right, just commented out the weird lines and replaced them
with your suggestions. Thanks for the numel(x) tip, cleans up the
thing a bit. Am I getting this error because of loopback or? I have
not connected it to the device yet, can't , I am building the
circuitry as I look through the old code and try to get it running. I
assumed that the above last error was because of that? It throws an
exception in fwrite, is the devices absence the culprit or? BTW,
thanks for the tips and help, this stuff is not like riding a bicycle
when you haven't touched MatLab in many years. Lord, I have forgotten
so much! C++ and C# and LabView has taken up all mu last decade for
the most part. Thing is, MatLab -is- necessary in many circumstances
despite the likes of LabView, darn LabView can become a convoluted
mess quickly when you're doing mathematical work. It's a darn
spaghetti factory, in my opinion to begin with. How a person doing
anything but instrumentation gets anything done beyond that is a
mystery to me. Glad I got back to MatLab, forgot how good it actually
was , and self-documenting..Do THAT with LabView and you'll win a
Nobel Priize...ha! Let me know, not trying to take up your time, just
this is pretty important to me. Has to do with visible light
communications , which I know to be the future of LED lighting. In
fact, i believe in its future so strongly that i have recently applied
for new patents. I already have 5. ;-) Work goes on, and thanks to
helpful people like you I don't have to sit here befuddled after years
of having MatLab in the background. Just can't do what i need to do
with LabView or the Miserysoft junk, believe it! Best Regards!
Jeffrey.

0
4/30/2012 9:06:10 PM
Jeffrey:
You're telling imwrite the file format is uint8, but that's not
right.  It is expecting something like BMP, TIF, PNG, JPG, etc.  It
already knows it's uint8 since it knows the class of the data you're
sending in - you don't need to tell it.  For that matter, you don't
need to tell it the file format (PNG, etc.) because it gets that from
the file extension.  It would only need that if your file name did not
have an extension (for some reason), or it had some strange extension
that you wanted to use for some reason and it couldn't figure out the
file format from your strange extension.  I don't recommend you do
that.  Just leave it out altogether and just pass in the data and the
full file name (folder+base file name + extension).  Use fullfile() to
build a complete filename, after of course you've used exist(folder,
'dir') to check that the folder exists and mkdir(folder) to create it
if the folder doesn't already exist.
0
imageanalyst (7621)
5/1/2012 12:15:48 AM
On Apr 30, 8:15=A0pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> Jeffrey:
Hi again,

Yes, I can see the uint8 is over-thinking it. And yes i can see
why that would throw an exception now that you mention it.
I am bad for that. Over-thinking things...You should see some of my
late-70's 80's CBASIC junk...Oh man. What a time that was. ;-)
If I remember correctly, there was a reason for doing that uint8 when
the
original code was forged , not sure now why but it's still a remnant
of a very experimental quick and dirty coding exercise, not nearly as
elegant as you have suggested. I appreciate your observations
very much - I'm still a hack as far as MatLab goes, It'll take
me a while to get back up on that horse but I have to. At least
until I get past resurrecting my old OOK circuitry and move on to
my new color phase shift keying/OFDM  stuff. No strange
extensions, so do I just hack out the uint8 refs and be done with
it? I am not familiar with fullfile() will look it up. As I say, if I
once
was, I don't remember now. Too many years, too many projects
later. An R&D engineer , like me, gets bombarded so much we
can't help refiling things in our brains, seriously, sometimes to
the point of just one step from completely forgetting what once
was a daily thing. I am sure you know the drill.

Anyhow, in so removing uint8's from the existing code, any
suggested best re-write for those lines? Ha, you probably
hate me by now for all these q's - but look, I really appreciate
your help. It'd take me way too long to figure out how to fix this
old bad copy of the programs if i didn't have some smart
help - no doubt!

You write this stuff for a living? Or part of it?

Might could use your help later too, but maybe a
payed gig. I'll see what I can do if you're interested.

Anyhow, get back about the uint8 re-hack if you have time.

THANKS BIG TIME ... !!! Best , quickest help I have received
on some weirdness in a programming lang. in forever, you're
really great to help out an old codger like me. People are
so smart-a$$ed and convinced they know everything
anymore, I rarely ask . The net used to be friendlier, the BBS's
were stellar. Nice to meet you. ;-)

Best Regards,

Jeffrey



> You're telling imwrite the file format is uint8, but that's not
> right. =A0It is expecting something like BMP, TIF, PNG, JPG, etc. =A0It
> already knows it's uint8 since it knows the class of the data you're
> sending in - you don't need to tell it. =A0For that matter, you don't
> need to tell it the file format (PNG, etc.) because it gets that from
> the file extension. =A0It would only need that if your file name did not
> have an extension (for some reason), or it had some strange extension
> that you wanted to use for some reason and it couldn't figure out the
> file format from your strange extension. =A0I don't recommend you do
> that. =A0Just leave it out altogether and just pass in the data and the
> full file name (folder+base file name + extension). =A0Use fullfile() to
> build a complete filename, after of course you've used exist(folder,
> 'dir') to check that the folder exists and mkdir(folder) to create it
> if the folder doesn't already exist.

0
5/1/2012 1:07:18 AM
Jeffrey:
I just realized my answer was for imwrite, not fwrite.  I think I got
confused when I saw imshow.  So disregard what I said.  Maybe I'm
getting old too.....  I've also been doing this since the 70's, and
using MATLAB since about 2006 or so.  I pretty much use MATLAB all day
long every day.
0
imageanalyst (7621)
5/1/2012 2:33:12 AM
Okay, so maybe it wasn't over-thinking it after all. Feel better about
that now...ha!
The crazy thing is still throwing that exception , so yeah, I dunno.
Maybe that'll
disappear once i connect the circuitry up. Right now, this particular
experiment
uses two TTL/USB converters still for the serial lines from DB-9's on
my circuit
its so old...ha! No problems with those, just this last error makes me
wonder
whats up. I think what you suggested before fixed the bulk of it, but
that
error is still a big question mark. So, imwrite works that way huh?
Good to know,
not sure I'll use it but still good to know. I can understand, you
probably use
imwrite a lot (or have in the past) could be easily confused for sure.
Any last
observations about why this is still throwing that fwrite exception? I
am lost
even worse under the hood of MatLab than the scripts...ha! I get 80%
or more
of what I am looking at in the scripting, despite the long hiatus.
Surprising
really. I guess if you've used it before and other text languages
there's always
structural similarities and command similarities that never quite go
away in
ones mind.

Best Regards, and thanks again. Still wondering about that error, darn
if I know.

Jeffrey




On Apr 30, 10:33=A0pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> Jeffrey:
> I just realized my answer was for imwrite, not fwrite. =A0I think I got
> confused when I saw imshow. =A0So disregard what I said. =A0Maybe I'm
> getting old too..... =A0I've also been doing this since the 70's, and
> using MATLAB since about 2006 or so. =A0I pretty much use MATLAB all day
> long every day.

0
5/1/2012 2:56:58 AM
Reply:

Similar Artilces:

Need help for a matlab mini project
Hello everyone, I have a matlab in class exercise due in few days. I am new to matlab and the instructions provided with the assignment is minimal. Can Someone help me with the basic understanding as in how can I map the problem's solution to matlab script ? I am not able to post question here as it is a jpeg file. Please let me know and then we can discuss further. ...

Matlab help
This is a small part of my whole project (Speech/Music Discrimination). I can wavread all the wave files when the code is in the current directory. Using this file=dir('*.wav'); for i=1:length(file); [s, fs]=wavread(file(i).name); commands statements etc, in here... end The problem is i want to used this code to other folders without moving it in that directory. For example there are wave files in the Musicvoice folder I edited the code to something like this to access the wave files in the Musicvoice. file=dir('Musicvoice\*.wav'); for i=1:length(file); [s, fs]=wavread(file(i).name); commands statements etc, in here... end It gave me the error below. Please help. ??? Error using ==> wavread Cannot open file. Error in ==> extractFeature at 16 [s, fs]=wavread(file(i).name); %wavread function returns s and the sampling frequency kingdavid3 wrote: > This is a small part of my whole project (Speech/Music > Discrimination). I can wavread all the wave files when the code is in > the current directory. > > Using this > > file=dir('*.wav'); > > for i=1:length(file); > > [s, fs]=wavread(file(i).name); > > commands statements etc, in here... > > end > > The problem is i want to used this code to other folders without > moving it in that directory. For example there are wave files in the > Musicvoice folder I edited the code t...

Contribute to MATLAB Central and Win a MATLAB Jacket
Many of you who post to this newsgroup are also regular contributors to the MATLAB Central File Exchange. Look for your favorite contributors on our File Exchange Author Profile page. You can read their profiles and see pictures: <http://www.mathworks.com/matlabcentral/reports/fileexchange/allProfiles/> In a random drawing, we recently awarded MATLAB jackets to three File Exchange authors with profile pages: Michele Giugliano, Andrey Egin, and Denis Gilbert. You can win a jacket, too. Just submit a new file to the File Exchange or update your author profile by December 2003 for a chance to win one of four MATLAB jackets. See the jacket below: <http://www.mathworks.com/matlabcentral/images/jeff3.jpg> Here are some interesting File Exchange facts: - Since its inception in 2001, visitors have downloaded more than 1.25 million submissions from the File Exchange. - In September 2003 alone, visitors downloaded 80,085 files, an average of 2670 a day! .... what if the prize was a free copy of the next version of Matlab :-) majb Min Poh wrote: ....or an offer for employment... aj "bourassa" <bourassa-m@rmc.ca> wrote in message news:3f9d507d$1@rmcnt03a.rmc.ca... > ... what if the prize was a free copy of the next version of Matlab :-) > > majb > > Min Poh wrote: > ...

Matlab parallel for loop or Matlab open pool
I am trying to to some computations and I would like to do it in parallel using parfor or by Opening the matlabpool.. as the current implementations is too slow: result=zeros(25,16000); for i = 1:length(vector1) % length is 25 for j = 1:length(vector2) % length is 16000 temp1 = vector1(i); temp2 = vector2(j); t1 = load(matfiles1(temp1).name) %load image1 from matfile1 t2 = load(matfiles2(temp2).name) % load image2 from matfile2 result(i,j)=t1.*t2 end end It work fine but I would really like to know if there is a way to speed thing up ... Thanks a lot in advance! ...

help new in MATLAB
Hi Maybe a too easy problem for you but maybe you help me to solve this in MATLAB I have a vector of point let say for example sin(x) from -PI to PI and I would like to plot the -- vector -- derivative of the vector -- integral of the vector any idea how do do this in MATLAB Thks On 8/5/2012 1:15 PM, mourad wrote: > Hi > Maybe a too easy problem for you but maybe you help me to solve this in > MATLAB > I have a vector of point let say for example sin(x) from -PI to PI > and I would like to plot the > -- vector > -- derivative of the vector > -- integral of the vector > doc plot doc diff doc trapz -- ...

Help with Parallel Matlab
Long story short, here is the criteria I need. 1) I need two modules running in parallel. One function must activate these two They don't need to START at the same time but both neither return info nor end. They run pretty much infinitely 1.1) I would prefer if the One function also ran separate from the above two in it's own loop but i can deal with a 3'rd function also not ending. 2) I need a shared variable between two of the modules. 1 Module will place information there while the other just reads it, but as they are running parallel. That's it. I can do this in pretty much any other language but matlab I've been having issues with. Problem is I absolutely need to use matlab for one module. If this is impossible to accomplish all in matlab then can i instead run this in C and call one matlab module with separate thread? Sample code below. function mainParallelTest() persistent counter; counter = 0; parfor i=0:2 if (i == 0) ImageProccessorParallelTest(); elseif(i == 1) EventProcessorParallelTest(); elseif(i == 2) prevCounter = 0; tempCounter = 1; while(true) tempCounter = counter; if (tempCounter == prevCounter) %disp('hi') end prevCounter = tempCounter; end end end "Alex Cruikshank" <cruiksam@gmail.com> writes: > Long story short, here is the criteria I need. >...

Need Help With Matlab
Hi I am trying to simulate the low pass filtered output of a square wav (pulse train) using Matlab. The pulse varies between 0 and 1. So th filtered output looks somewhat like a sinewave. The filter is a low pas filter (FIR/raised cosine filter). Essentially what I need is to be abl to generate a look up table that will store the output waveform rise fall transition (from 0-1 and 1-0). So what i want essentially is to b able to generate a look up table of different lengths (like 100,50 etc) t store these transitions. I tried using Simulink for this, but havent bee successful so far. So my table will look something like 1 0.995 0.923 0.91 0.85 ..... to 0 Any help is highly appreciated. Thanks. Best regards Vikram ...

Matlab LVQ Help
Hi, I am new on neural network toolbox. I am trying to use LVQ algorithm,but it is not working at all. Right now I am trying to train the network for a simple sine curve, but it is not trained according to the target. Can you help me with your suggestion, my function is y=sin(x); x is my input and y is my target output. I classified target results in four different classes. 0.5<=value<=1.0; class 1 0.0<=value<0.5; class 2 -0.5<=value<0.0; class 3 -1<=value<-0.5; class 4 I would highly appriciate if you help me with some idea, i am stucked here for a long time. Here is the code I am using, --------------------------------------------------- t=-5:.1:5; x=t; for i=1:length(x) y(i)=sin(x(i)); end for i=1:1:length(y) if(0.5<(y(1,i)) && (y(1,i))<=1) tc1(1,i)=1; end end for i=1:1:length(y) if(0<=(y(1,i)) && (y(1,i))<0.5) tc1(1,i)=2; end end for i=1:1:length(y) if(-0.5<=(y(1,i)) && (y(1,i))<0) tc1(1,i)=3; end end for i=1:1:length(y) if(-1.0<=(y(1,i)) && (y(1,i))<-0.5) tc1(1,i)=4; end end p1=x; check(1,:)=p1; check(2,:)=tc1; checkall=sortrows(check,2); p=checkall(1,:); tc=checkall(2,:); t=ind2vec(tc); targets=full(t); sc=16; calu(1,1)=sum(targets(1,:)); calu(2,1)=sum(targets(2,:)); calu(3,1)=sum(targets(3,:)); calu(4,1)=sum(targets(4,:)); c1=calu(1,1)/(sum(calu(1,1)+calu(2,1)+calu(3,1)+calu(4,1))); c2=calu(2,1)/(sum(calu(1,1)+calu(2,1)+calu(3,1)+calu(4,1))); c3=calu...

Call Matlab m-file from Matlab Scrip Node
My problem with matlab script node is related to calling function in matlab.&nbsp; I created an m-file function that takes an imput temperature (from DAQ) and defines a material property.&nbsp; My matlab script node doesn't seem to recognize my function.&nbsp; I have placed the function in the folder the vi is currently located, but it doesn't read it.&nbsp; How do I get matlab script node to read the functions I create in matlab? Add the directory to matlab path, or call the .m file with it full name ( D:\..... \myfile.m) Let me clarify, &nbsp; I have pasted my matlab code into the matlab scrip node. &nbsp; In this code, I have called a subfunction that I have created. &nbsp; Example k(n)=k_c(T(n)) where k_c is a subfunction I have created. &nbsp; How do I get my code in the node&nbsp;to sucessfully read the subfunction k_c? &nbsp; &nbsp; &nbsp; As indicated, you need to add the directory where the .m file containing the function resides to the list of paths that are read in. This is your startup.m file. The other option is to do a "cd" command prior to calling your function to change to the directory where the .m file containing the function resides. Thanks for reiterating the information.&nbsp; My matlab script node is working properly.&nbsp; I had never used the "cd" command in matlab.&nbsp; I always set the working directory when I open the program, and put all the m files into t...

need help in matlab implementation
Is their anybody help me in calculating the bit error rate of OFDM SIGNAL for BPSK, QPSK AND QAM SIGNAL in the papr reduction techniques like clipping and Selective level mapping, if anyone is having coding for the same please mail me on pmjadhav85@gmail.com. ...

matlab programming help #2
can anyone tell me whats wrong with this? =[ function[y]=horner_scheme (a,x) n = 1:n; b(n)=a(n); for i=n-1:-1:0 b(i)=((b(i+1))*x)+a(i); end y = b(0); im pretty sure all is right, except i keep getting the message 'the variable n can be used before it is defined' =S (line 2..) what does that mean? "matlabnoob noob" <counternoob@hotmail.co.uk> wrote in message news:gouo8d$rdl$1@fred.mathworks.com... > can anyone tell me whats wrong with this? =[ > > function[y]=horner_scheme (a,x) > n = 1:n; > b(n)=a(n); > for i=n-1:-1:0 > b(i)=((b(i+1))*x)+a(i); > end > y = b(0); > > > im pretty sure all is right, except i keep getting the message 'the > variable n can be used before it is defined' =S (line 2..) > > what does that mean? What do you think the value of n is? What are you trying to achieve with the line n=1:n; ? Arnaud "matlabnoob noob" <counternoob@hotmail.co.uk> wrote in message <gouo8d$rdl$1@fred.mathworks.com>... > can anyone tell me whats wrong with this? =[ > > function[y]=horner_scheme (a,x) > n = 1:n; > b(n)=a(n); > for i=n-1:-1:0 > b(i)=((b(i+1))*x)+a(i); > end > y = b(0); > > > im pretty sure all is right, except i keep getting the message 'the variable n can be used before it is defined' =S (line 2..) > > what does that mean? No, you are not getting it right. You were told in your...

Matlab Audioplayer code help!
Hey, So im reworking a code. GUI with 3 buttons, all 3 button play songs when loaded from a file, So im using Audioplayer and its playing Button 1, but when i press button 2, Button 1 is still playing and button 2 also plays and so on with button 3... So my question is, what do I do so when Button 1 is playing and I press Button 2, Button 1 music is stopped and Button 2 music starts playing, same with Button 3. (I dont want to add any other buttons, I want it to stop automatically when I press other button and plays that song). function myplay(file) if isunix, %using system's play (from the sox package) on Unix (MATLAB's sound does not work) [s,w]=unix(['play ' file]); else, %using MATLAB's wavplay on Windows [y,fs]=wavread(file); player=audioplayer(y,fs); play(player); pause(max(size(y))/fs); end ...

bar
In MatLab 6.5, the routine above works normal: figure; sem=Average(:,2)./sqrt(Average(:,3)); bar([1:1:7],Average(:,1),sem); ylabel('% of epochs analyzed') xlabel('Frequency Band') title ('Occurrence of Oscillatory Events - Ch X') %Where Average and sem are vectors; But, in MatLab 7.0, the same code cause the following error: ??? Error using ==> xychk Too many input arguments. Error in ==> bar at 53 [msg,x,y] = xychk(args{1:nargs},'plot'); Error in ==> cross_subj_analysis>ok_Callback at 327 bar([1:1:7],Average(:,1),sem); I'd like to know why this occour. Thanks Henrique In article <g7a1j6$l1$1@fred.mathworks.com>, Henrique Amaral <henriquetomaz@uol.com.br> wrote: >In MatLab 6.5, the routine above works normal: >figure; >sem=Average(:,2)./sqrt(Average(:,3)); >bar([1:1:7],Average(:,1),sem); >ylabel('% of epochs analyzed') >xlabel('Frequency Band') >title ('Occurrence of Oscillatory Events - Ch X') >%Where Average and sem are vectors; >But, in MatLab 7.0, the same code cause the following error: >??? Error using ==> xychk >Too many input arguments. >Error in ==> bar at 53 > [msg,x,y] = xychk(args{1:nargs},'plot'); >Error in ==> cross_subj_analysis>ok_Callback at 327 >bar([1:1:7],Average(:,1),sem); >I'd like to know why this occour. When the third argument is numeric, it must be the bar width. barwidth must b...

Matlab builder JA: parse java string to matlab cell
Hi all, I'm building a java swing based GUI for my Matlab application. As such, user input is available as text strings, for example "{[0; 0], [3.5 0; 0 2]}" (mean vector and covariance matrix of a 2D Gaussian). The user input will be passed to the compiled matlab method as a MWCellArray. Problem is how do a convert (parse) the above string into a MWCellArray? From its javadoc http://www.mathworks.com/access/helpdesk/help/toolbox/javabuilder/MWArrayAPI/index.html the following method is available: java.lang.String toString() Returns a string representation of this array, but the reverse method is not. Evidently, parsing a string like the one above is a non trivial task and I'm loath to attempt writing one by myself. I would be very thankful if someone can point me to the required parser implementation. Matlab itself is carrying out this task all the time, perhaps it is possible to access Matlab's own parser. Help much appreciated, Ritesh ...

Help: Optimization using Matlab
Hello all, I need to find the optimal value of x for the function (1- x^2/2R^2)^(1/x) in terms of R. Could someone please help, how I could do it in Matlab? Thanks a million, --Johnson fminsearch or fminbnd User10 wrote: > > > Hello all, > > I need to find the optimal value of x for the function (1- > x^2/2R^2)^(1/x) > in terms of R. > Could someone please help, how I could do it in Matlab? > > Thanks a million, > --Johnson > > > ...

some problems of codes of MATLAB 7.0 working on MATLAB 6.5
I have used MATLAB for few hours.So I don't know the differences between version 6.5 and 7.0.I want to use some codes of MATLAB 7.0, but they doesn't work in MATLAB 6.5.How to change these codes so that they can work in matlab 6.5.Waiting for your help. Thank you . The codes are like this .I think changing the function findPI may work ,but I don'y know how % PIfun.m % Evaluate a function used to find the PI-line, using Kyle Champley's % method. % % Adam Wunderlich % last update: 5/18/06 function y = PIfun(r,R,h,gamma,x3,sb) temp = R - r*cos(gamma-sb); y = h*((pi - 2*atan(r*sin(gamma-sb)/temp))*(1 + (r^2 - R^2)/ (2*R*temp)) ... + sb) - x3; % find_PI_Line.m % % Find the the parametric interval corresponding to the unique PI-line % passing through the point x for a given helical pitch. % This code implements the method of Kyle Champley. % inputs: P = pitch (cm/turn), R = helix radius, delta_s = s stepsize, x % output: PI = [sb st] % % Adam Wunderlich % last update: 5/18/06 function [PI] = findPI(P,R,delta_s,x) h = P/(2*pi); r = sqrt(x(1)^2+x(2)^2); gamma = atan2(x(2),x(1)); options = optimset('TolX',h*delta_s/100,'FunValCheck','on'); [sb,fval,exitflag] = fzero(@(sb) PIfun(r,R,h,gamma,x(3),sb),... [(x(3)-h*pi)/h,x(3)/h],options); if exitflag ~=1, disp('Error: PI invalid'); end % note that beta=sb in Kyle's formula alphaX = atan(r*sin(gamma-sb)/(R - r*cos(gamma-sb))); st = sb + pi -...

can't run matlab setup/No puedo correr matlab
Hi! I opened the&nbsp;matlab script fractal.vi&nbsp;then my antivirus (Kaspersky)&nbsp;ask&nbsp;if I acept the modified te registry of matlab setup,&nbsp; I &nbsp;say "yes" After that when I want open matlab the setup run but inmediatly it's close, why???? &nbsp; Hola: Abri el matlab script fractal.vi y mi antivirus (Kasoersky)me preguntaba si aceptaba una modificacion del registro del setup de matlab yo acepte Despues de eso cuanto abro matlab se cierra inmediatamente porque?? &nbsp; &nbsp; &nbsp; Hola Sa�l Es probable que el problema est� relacionado con el antivirus Kaspersky, trata de deshabilitarlo y correr nuevamente el ejemplo.&nbsp; Si esto no funciona revisa el estado de tus licencias de LabVIEW y de Matlab, probablemente tengas que reinstalar el programa y/o activar las licencias. �Qu� versi�n de LabVIEW y Matlab tienes? �El comportamiento es el mismo con el otro ejemplo?, me refiero al de la siguiente dir: labview\examples\scriptnode\Differential Equation.llb\MATLAB Script - Lorenz Diff Eq.vi Si corres este ejemplo �El antivirus tambi�n te pregunta cambiar lo de los registros?, ser�a bueno contactar a Mathworks para saber c�mo reconfigurar nuevamente los registros de Matlab ...

numerical method in matlab, please help
Hi everybody I'm desperate. I'm preparing a program in matlab and really i'm having to many problems. In a matrix 10x10, i want to solve laplace's equation with an iterative method in a 2 dimensional space. I have a mountain defined by zeros in the matrix. I want to calculate the speed and direction of the wind, setting the next boundary conditions: Upper part: no vertical fluid lower part at both sides of mountain: no verical fluid lateral: only a constant and horizontal fluid My problem is the mountain. How can I program the method so that the fluid in the border of the mountain is tangent?? Really I need help, don't know what to do. I have tried some options and I cannot make the method to converge! Any help would be appreciated Thanks a lot in advance and sorry for my english Inigo ...

help regarding Matlab to C conversion
Hi all, I have written some code in Matlab. Can i directly convert this ".m" file into C code (.c/.cpp file). If there is anytool in Matlab or anywhere please tell me . thanks and regards yogesh You will need the MATLAB compiler (mcc) for which a separate licence is required. <help mcc> Roy http://www.danielsorogon.com/Webmaster "yogesh kumar" <yogesh_kec@rediffmail.com> wrote in message news:qo1gtbpi9sha@legacy... > Hi all, > I have written some code in Matlab. Can i directly convert this > ".m" file into C code (.c/.cpp file). If there is anytool in Matlab or > anywhere please tell me . > thanks and regards > yogesh > ...

Need some advice on matlab.pls help
Hi all, i am using matlab and encountered some problems. Kindly advice. 1)i am using newff function to create a neural network.After which someone advised me to set some of the parameters ,for example net.performFcn,net.trainParam.goal and many more. But i tried using m matlab help and search for function to llok up for what these parameter do. However, i can't find any help on these parameters. Where can i fin them? 2)i intend to use the train function to train my network. In the trai function, according to the help file,we can also give T(network targets as input. Can someone kindly explain to me what is network targets? 3)while processing the image,i came across something like y=[13x logical], what does it mean? Why cant i look into the content? When i tr to do sum(y(:,1)), it gives an error saying "Function 'sum' is not define for values of class 'cell'." However, if i use it in an while loo comparison statement, there is no error. Why? 4)If i want to do hardware implementation,i have to convert my code i matlab to C++, am i right? If so, is there anyway to do so or must i writ them out in C++ format all over again? Thanks & Regards doggie skrev: > Hi all, i am using matlab and encountered some problems. Kindly advice. If you have general questions about matlab, comp.soft-sys.matlab would probably be a better place to start. DSP-related questions involving matlab are likely to be answered here. > 4)If i want to do hardwa...

help on parfor and file-management in Matlab
hii everyone. please tell me, how to use 'parfor' function ? it's syntax(es) and the Matlab version(s) which support 'parfor'. also, if possible, please tell me how to realise 'file-management' in Matlab environment; the commands and the rules for it. ------- ashutosh srivastava "ashutosh srivastava" <srivastava_ashu1987@in.com> writes: > please tell me, how to use 'parfor' function ? it's syntax(es) and > the Matlab version(s) which support 'parfor'. PARFOR was introduced in R2007b of MATLAB. The doc is here: <http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/brb2x2l-1.html> Cheers, Edric. thanks Edric for your assistance. ...

Sound Localization Matlab, Please Help!
As part of my college engineering thesis, I have been assigned the task of identifying and locating sounds using MATLAB. So far, all I have is a two-microphone set-up, which comprises the audio signal for analysis. This is split up into two vectors in matlab, and using the time delay information, I need to be able to locate the sound. I've done a fairly basic frequency analysis just to get some background information on the sound, but now I need to output the distance and angle as answers! Any information would be greatly appreciated, as all of the resources on the internet tend to go into advanced acoustic theory which is way over my head! staplep wrote: > As part of my college engineering thesis, I have been assigned the task of > identifying and locating sounds using MATLAB. So far, all I have is a > two-microphone set-up, which comprises the audio signal for analysis. This > is split up into two vectors in matlab, and using the time delay > information, I need to be able to locate the sound. I've done a fairly > basic frequency analysis just to get some background information on the > sound, but now I need to output the distance and angle as answers! Any > information would be greatly appreciated, as all of the resources on the > internet tend to go into advanced acoustic theory which is way over my > head! Location is usually accomplished by measuring the difference between the delays of pairs of signals. Barring reflections tha...

Newbie in matlab..need help urgently!
I am trying to implement a bandpass filter on a signal data, xx. It is of 200,000 samples and the sampling frequency is 40 kHz. I am using a butter filter function and my program is as followed: HalfFs = Fs/2 Wp = [1000 1550]/HalfFs; Ws = [950 1600]/HalfFs; Rp = 3; Rs = 40; %Calculate the minimum order of Butterworth filter [n,Wn] = buttord(Wp,Ws,Rp,Rs) [b,a] = butter(n,Wn); yy - filter (b,a,xx); xx = conv(xx,yy); my program always hang upon the convolution step...does anybody knows how to solve this program? Should work, but try storing convolution output to something other than an input, e.g. zz = conv(xx,yy); xx = zz; You should also try a smaller sequence, say 10000 samples, first and then increase the size slowly. Sometimes matlab, because it allows dynamically resizing arrays, can get stuck in malloc cycles or memory swaps and can seem to take forever. Especially if your machine doesn't have a lot of memory. -Clark <buggue@hotmail.com> wrote in message news:1142156054.386572.263770@u72g2000cwu.googlegroups.com... > I am trying to implement a bandpass filter on a signal data, xx. It is > of 200,000 samples and the sampling frequency is 40 kHz. > > I am using a butter filter function and my program is as followed: > > HalfFs = Fs/2 > Wp = [1000 1550]/HalfFs; Ws = [950 1600]/HalfFs; > Rp = 3; Rs = 40; > > %Calculate the minimum order of Butterworth filter > [n,Wn] = buttord(Wp,Ws,Rp,Rs) > > [b,a] = butter(n,Wn); ...

Incompatible of MAT file for Matlab 6.5.1 and Matlab 7.0
Hi! I have recently installed Matlab 7.0. I have save my simulation results in .MAT file. However, these MAT files can't be opened using Matlab 6.5.1. I encountered problem as follows: ??? Error using ==> load Unable to read MAT file D:\MATLAB7\work\results.mat File may be corrupt. How can I solve this problem? Thanks. Linda Please see here: <http://tx.technion.ac.il/~perryb/matlab7/mat7.pdf> In short, save again as: The new features and enhancements are described in the "Release notes" of Matlab. A new feature that causes incompatibility with previous versions of Matlab is the new encoding of MAT files. Matlab release 14 writes character and figure data to MAT-files using Unicode encoding by default. Unicode encoded MAT-files are not readable by earlier versions of Matlab. If you intend to load your MAT-files created with Matlab release 14, you must override the Unicode default during the save. You can override the default encoding by using the -v6 switch with save and hgsave: save filename -v6 hgsave filename -v6 Hope it helps Linda wrote: > > > Hi! > > I have recently installed Matlab 7.0. > I have save my simulation results in .MAT file. > However, these MAT files can't be opened using Matlab 6.5.1. > > I encountered problem as follows: > > ??? Error using ==> load > Unable to read MAT file D:\MATLAB7\work\results.mat > > File ma...

Web resources about - MatLab help #27 - comp.soft-sys.matlab

Undocumented Matlab
Undocumented, unsupported and hidden features in Matlab

Matlab Upazila - Wikipedia, the free encyclopedia
... 23°21′N 90°42.5′E  /  23.35°N 90.7083°E  / 23.35; 90.7083 Coordinates : 23°21′N 90°42.5′E  /  23.35°N 90.7083°E  / 23.35; 90.7083 Matlab ...

Open Directory - Science: Math: Software: MATLAB
The MathWorks - Developers of MATLAB, Simulink and Stateflow. Offers products for data analysis, visualization, application development, simulation, ...

MATLAB Mobile on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about MATLAB Mobile. Download MATLAB Mobile and enjoy it on your iPhone, ...

The Smart Emergency Response System Using MATLAB and Simulink - YouTube
In the aftermath of an earthquake, every second counts for disaster victims. Imagine a system that can locate people quickly and help first responders ...

The A-Z of Programming Languages: MATLAB
What prompted the development of MATLAB?

Matlab: Invalid .NET Framework. Either the specified framework was not found or is not currently supported ...
If you are trying to compile Matlab into .Net framework, you might encounter this message, even though you have the .Net framework installed ...

Matlab edges closer to electronic design automation world
Matlab, one of the world's most widely used products for algorithmic development, has long occupied its own niche far removed from EDA and hardware ...

Can I/How do I use DMTCP with a parallel pool of MATLAB workers? · Issue #223 · dmtcp/dmtcp · GitHub
dmtcp - DMTCP: Distributed MultiThreaded CheckPointing matlab -nodisplay -r "parpool('local',4); parfor i=1:10, pause(1); fprintf('%i ',i); end; ...

Using MATLAB and SDR to Reverse Engineer 433MHz Messages
... so he focused on studying the methodology and the tools available for analyzing 433MHz RF transmission. He describes the process of using MATLAB ...

Resources last updated: 3/30/2016 12:39:28 PM