From: khan Sim on 10 May 2010 06:15 i am working on the matlab embedded function, i am facing a problem in converting the code given below to matlab embedded code, I=find(afsb0 > amp_max*P_max); nI=length(I); fsb0(I)=((amp_max*(P_max^2)*ones(1,nI))./afsb0(I)).* ... exp(cj*angle(fsb0(I))); The variable I is not defined/initialized before, afsb0 is a complex double matrix of order 1x512, amp_max and P_max are two scalars. How can make the above code compatible with matlab embedded code, have the same effect. thanx
From: Michael Hosea on 10 May 2010 17:47 You sure afsb0 is complex? I would have thought you'd want it to be real (e.g., abs(fsb0)) if you were going to compare "absf0 > amp_max*P_max". If so, I think your code *should* work in R2009b and later, but I can't be sure without checking. Anyway, I never use FIND in Embedded MATLAB, even though it is supported now. How about for k = 1:length(fsb0) if afsb0(k) > amp_max*P_max fsb0(k) = (amp_max*(P_max^2)./afsb0(k)).*exp(cj*angle(fsb0(k))); end end -- Mike "khan Sim" <akhun85(a)yahoo.com> wrote in message news:hs8mbd$au6$1(a)fred.mathworks.com... > > i am working on the matlab embedded function, i am facing a problem in > converting the code given below to matlab embedded code, > > I=find(afsb0 > amp_max*P_max); > nI=length(I); > fsb0(I)=((amp_max*(P_max^2)*ones(1,nI))./afsb0(I)).* ... > exp(cj*angle(fsb0(I))); > The variable I is not defined/initialized before, afsb0 is a complex > double matrix of order 1x512, > amp_max and P_max are two scalars. > > How can make the above code compatible with matlab embedded code, have the > same effect. > > thanx
From: khan Sim on 11 May 2010 01:34 sir micheal hosea, bundles of thanks for your reply. sorry it was typed by mistake, afsb0 is real but fsbo is complex. thank you very very much.
From: khan Sim on 12 May 2010 00:34 well i am facing another problem while executing the code written by you. i want to use this code as a function in matlab embedded function block. function fsb0 = fcn(amp_max,P_max,afsb0) %#eml fsb0=zeros(1,512); for k = 1:length(fsb0) if afsb0(k) > amp_max*P_max fsb0(k) = (amp_max*(P_max^2)./afsb0(k)).*exp(sqrt(-1)*angle(fsb0(k))); end end when i run the simulation of this function block, i face errors like, "Embedded MATLAB Interface Error: Simulation stopped due to out of bounds error. Block Embedded MATLAB Function2 (#55) While executing: none" kindly guide me here, thanx kind regards
From: khan Sim on 12 May 2010 01:39 well the latest progress is when i used the following code using the matlab embedded function block, errors were given function fsb0 = fcn(amp_max,P_max,afsb0) %#eml fsb0=zeros(1,512); cj=sqrt (complex(-1)) for k = 1:length(fsb0) if afsb0(k) > amp_max*P_max fsb0(k) = (amp_max*(P_max^2)./afsb0(k)).*exp(cj*angle(fsb0(k))); end end when i run this code in the matlab embedded coder the following error is given. "The left-hand side has been constrained to be non-complex, but the right-hand side is complex. To correct this problem, make the right-hand side real using the function REAL, or change the initial assignment to the left-hand side variable to be a complex value using the COMPLEX function. Function 'Embedded MATLAB Function2' (#54.151.214), line 7, column 9: "fsb0(k) = (amp_max*(P_max^2)./afsb0(k)).*exp(cj*angle(fsb0(k)))" Launch diagnostic report." Kindly help me out in this regard thanx
|
Next
|
Last
Pages: 1 2 Prev: remove space between subplots Next: Plotting a 3-D line plot with user defined axis. |