Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

12-24-2012 12:44 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thanks.. Here's the matlab code and the vi is attached. When I make changes, I start getting errors like matrix dimension exceeded. error 1050, 1047. I restart matlab and it starts to work but same strategy doesn't apply everytime. Can someone plz tell me what's going on inside which stops the program?

Matlab

S=400;

n_eff_re=linspace(0.5,1.5,S);

n_eff_im=linspace(0.06,0.15,S);

c=299792458;

a=0.1e-6;

b=0.1e-6;

L=a+b;

na=1;

n=[2.89 3.38];

lambda = 1.15e-6;

omega = 2*pi*c/lambda;

beta_re=n_eff_re.*omega/c;

beta_im=n_eff_im.*omega/c;

W=zeros(S);

N=10;

for i = 1:S

for j=1:S

beta_c = beta_re(i) + 1i*beta_im(j);

k = [sqrt((omega*n(1)/c)^2 - (beta_c^2)) sqrt((omega*n(2)/c)^2 - (beta_c^2))];

A = exp(-1i*k(1)*a)* ((cos(k(2)*b) - (1i/2)*(k(2)/k(1) + k(1)/k(2))*sin(k(2)*b)));

D = conj(A);

B = exp(1i*k(1)*a)*((-1i/2)*(k(2)/k(1) - k(1)/k(2))*sin(k(2)*b));

C = conj(B);

K = (1/L)*(acos((A+D)/2));

q_a = sqrt(beta_c^2 - (omega*na/c)^2);

q = sqrt(beta_c^2 - (omega*n(1)/c)^2);

W(i,j)=abs((A+((q_a - q)/(q_a +q))*C)*(sin(N*K*L)/sin(K*L))-((sin((N-1)*K*L))/(sin(K*L))));

end

end

contourf(n_eff_re,n_eff_im,W)

a=0.1e-6;

b=0.1e-6;

L=a+b;

na=1;

n=[2.89 3.38];

lambda = 1.15e-6;

omega = 2*pi*c/lambda;

beta_re=n_eff_re.*omega/c;

beta_im=n_eff_im.*omega/c;

W=zeros(S);

N=10;

for i = 1:S

for j=1:S

beta_c = beta_re(i) + 1i*beta_im(j);

k = [sqrt((omega*n(1)/c)^2 - (beta_c^2)) sqrt((omega*n(2)/c)^2 - (beta_c^2))];

A = exp(-1i*k(1)*a)* ((cos(k(2)*b) - (1i/2)*(k(2)/k(1) + k(1)/k(2))*sin(k(2)*b)));

D = conj(A);

B = exp(1i*k(1)*a)*((-1i/2)*(k(2)/k(1) - k(1)/k(2))*sin(k(2)*b));

C = conj(B);

K = (1/L)*(acos((A+D)/2));

q_a = sqrt(beta_c^2 - (omega*na/c)^2);

q = sqrt(beta_c^2 - (omega*n(1)/c)^2);

W(i,j)=abs((A+((q_a - q)/(q_a +q))*C)*(sin(N*K*L)/sin(K*L))-((sin((N-1)*K*L))/(sin(K*L))));

end

end

contourf(n_eff_re,n_eff_im,W)

12-26-2012 06:35 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi kikki,

I would recommend checking out these KnowledgeBase Articles for common reasons for these errors:

Why Do I Get Error 1047 When Trying to Use The MATLAB Script Node in LabVIEW?

Error 1050 Occurred in MATLAB Script Node: Complex Values Cannot be Converted to Chars.

Like altenbach and RavensFan suggested, have you tried transposing the array to see if this resolves the issue?

Allison M.

Applications Engineer

National Instruments

ni.com/support

Applications Engineer

National Instruments

ni.com/support

04-17-2014 09:43 AM - edited 04-17-2014 09:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hello!

I know this thread is old, but it seems am experiencing some similar problems. But even simpler.

I have some recorded data, at 100Hz, and I load them and compute the derivative. In Matlab is pretty smooth (I am executing with only disctrete time samples and so on, and when I zoom I can see the stairs each 0.01s, so is fine), but when the same is done in Labview I can see some short of "undersampling", which does not occur all time, and therefore the derivative goes crazy. I attach the graph cmparison for 10sec. Top is matlab (yellow uploaded siganl and magenta de derivative) and down is labview (white uploaded signal and red derivative).

04-17-2014 10:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

We probably would need to see some code. Make sure to use exactly equivalent functions in both scenarios.

04-18-2014 02:06 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hello, thank you for your reply. I actually use the same code, because I am usig formula Node in Labview and a script in matlab. Basically what it does is:

TS[1]=-RawData[4]*pi/180;

TS[2]=(TS[1]-TS_Ant[1])/T;

TS[2]=(T*TS[2]+0.02*TS_Ant[2])/(0.02+T);

So is extracting one elemnt of a big vector and computing the filtered derivative. Actually RawData is a big matrix with 4000samples of a 11 element vector. So I use a foor loop to extract sequentially each item

04-18-2014 02:11 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

How hard would it be to attach actual code?

04-18-2014 02:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Sorry, I did not want to fill everything with uploads. Here I attache the Labview program I am using to figure out what is wrong

I think maybe is something it does when uploading the RawData into de model...I cannot upload the RawData, is too big 😞

04-18-2014 08:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Did you adjust for the fact that Matlab array indexes start at 1 while LV array indexes start at 0?

Lynn

04-18-2014 08:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Yeap, I took special care with that

04-18-2014 10:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

can you attach a small input file that has only 2 or 3 rows?

Can you tell us what the matlab output is for this data?

Can you also show us the matlab code?

(Some quick glances: I would eliminate the local variable "T" and wire directly to thet terminal. Now you can even delete the big sequence structure. Why is "TS_Ant" initilized with an array of size 155? You never seem to go that high. The first element of the TS array written to the output file will always be zero, is that intentional?)