Category: Matlab
Category Archives: Matlab
How can I access the comp.soft-sys.matlab newsgroup without Usenet newsgroup access?
Is there any site which carries up to date news for the comp.soft-sys.matlab Usenet newsgroup which I can access even if my site does not support NNTP access?Is there any site which carries up to date news for the comp.soft-sys.matlab Usenet newsgroup which I can access even if my site does not support NNTP access? Is there any site which carries up to date news for the comp.soft-sys.matlab Usenet newsgroup which I can access even if my site does not support NNTP access? comp.soft-sys.matlab, without, usenet, newsgroup, access, cssm MATLAB Answers — New Questions
Measurement of open circuit voltage of PV panel in simulink
When I try to measure open circuit voltage between + and – on simulink PV panel, I always get Nan. How can I measure the open circuit voltage ?When I try to measure open circuit voltage between + and – on simulink PV panel, I always get Nan. How can I measure the open circuit voltage ? When I try to measure open circuit voltage between + and – on simulink PV panel, I always get Nan. How can I measure the open circuit voltage ? pv panel MATLAB Answers — New Questions
NARX DNN: hidden layers and activation function
Hi there, can you please tell me how to set the number of hidden layers and the activation function of the output layer in a NARX network? It seems that I can only use one hidden layer and the linear function in the output layer.Hi there, can you please tell me how to set the number of hidden layers and the activation function of the output layer in a NARX network? It seems that I can only use one hidden layer and the linear function in the output layer. Hi there, can you please tell me how to set the number of hidden layers and the activation function of the output layer in a NARX network? It seems that I can only use one hidden layer and the linear function in the output layer. narnet, autorregressive, narx MATLAB Answers — New Questions
GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR
Will this example work as a GPS Spoofer (GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR) ??Will this example work as a GPS Spoofer (GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR) ?? Will this example work as a GPS Spoofer (GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR) ?? gps spoofer, gps MATLAB Answers — New Questions
How do you indicate a line between a user and a GPS satellite?
The distance between the satellite and the user was obtained, but it was obtained with the ECEF coordinate system.
If you use ecef2enu, a function that changes the distance to the ENU coordinate system, errors continue to occur. I am curious about the solution, and furthermore, I want to use the unit vector to reduce the distance and then visualize the satellite-user distance.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime(‘now’, ‘TimeZone’, ‘Local’);
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid(‘meters’);
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX – recX)^2 + (satY – recY)^2 + (satZ – recZ)^2);
end
disp(‘Satellite location:’);
disp(satPos);
disp(‘Receiver location:’);
disp([recX, recY, recZ]);
disp(‘Satellite-Receiver distances:’);
disp(distances);The distance between the satellite and the user was obtained, but it was obtained with the ECEF coordinate system.
If you use ecef2enu, a function that changes the distance to the ENU coordinate system, errors continue to occur. I am curious about the solution, and furthermore, I want to use the unit vector to reduce the distance and then visualize the satellite-user distance.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime(‘now’, ‘TimeZone’, ‘Local’);
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid(‘meters’);
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX – recX)^2 + (satY – recY)^2 + (satZ – recZ)^2);
end
disp(‘Satellite location:’);
disp(satPos);
disp(‘Receiver location:’);
disp([recX, recY, recZ]);
disp(‘Satellite-Receiver distances:’);
disp(distances); The distance between the satellite and the user was obtained, but it was obtained with the ECEF coordinate system.
If you use ecef2enu, a function that changes the distance to the ENU coordinate system, errors continue to occur. I am curious about the solution, and furthermore, I want to use the unit vector to reduce the distance and then visualize the satellite-user distance.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime(‘now’, ‘TimeZone’, ‘Local’);
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid(‘meters’);
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX – recX)^2 + (satY – recY)^2 + (satZ – recZ)^2);
end
disp(‘Satellite location:’);
disp(satPos);
disp(‘Receiver location:’);
disp([recX, recY, recZ]);
disp(‘Satellite-Receiver distances:’);
disp(distances); gps, gnss, unit vector, ecef, enu MATLAB Answers — New Questions
How to change resolution of an image ?
What is the command/keyword for changing resolution(ppi) of image in matlab? How we can use that command? Please kindly give an exampleWhat is the command/keyword for changing resolution(ppi) of image in matlab? How we can use that command? Please kindly give an example What is the command/keyword for changing resolution(ppi) of image in matlab? How we can use that command? Please kindly give an example image processing, digital image processing MATLAB Answers — New Questions
Detection of disconnected server when using tcpclient() and write()
I am using the tcpclient() function to establish a connection to a server I built and I would like to be able to detect when the server disconnects. My current understanding is that the way to do that is to attempt a write and if the write fails, the connection can be considered as disconnected.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434); %connects to server
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
The above code works fine as expected.
Next, I run the same code, but I disconnect the server after the connection is established but before the write is sent.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
write(t,msg); % sends message to disconnected server. "An established connection was terminated. Please create a new TCPCLIENT." is shown in command window
write(t,msg); % sends message to disconnected server. "Invalid or deleted object." is shown in command window.
I can handle the last 2 errors using a try/catch, but I am not able to handle the "Error using asyncio.MessageHandler/onError" error with a try/catch.
I think this is because the error is raised asynchronously. I would like to be able to catch this error to avoid error messages in the final application.
According to the tcpclient page, there is a callback property called ErrorOccurredFcn that seems to be built to handle that.
However, even with the following code, I still get the same "Error using asyncio.MessageHandler/onError" error and my error handler function is not executed.
function error_handler()
disp("Asynchronous error handled"); % never executed
end
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
t.ErrorOccurredFcn = @error_handler;
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
So, I still get an error in the command window after using the ErrorOccurredFcn callback property.
The read() command does not seem to raise an exception whenever the server is disconnected.
So, what is the proper way to detect if the server is disconnected without getting an error in the command window?I am using the tcpclient() function to establish a connection to a server I built and I would like to be able to detect when the server disconnects. My current understanding is that the way to do that is to attempt a write and if the write fails, the connection can be considered as disconnected.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434); %connects to server
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
The above code works fine as expected.
Next, I run the same code, but I disconnect the server after the connection is established but before the write is sent.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
write(t,msg); % sends message to disconnected server. "An established connection was terminated. Please create a new TCPCLIENT." is shown in command window
write(t,msg); % sends message to disconnected server. "Invalid or deleted object." is shown in command window.
I can handle the last 2 errors using a try/catch, but I am not able to handle the "Error using asyncio.MessageHandler/onError" error with a try/catch.
I think this is because the error is raised asynchronously. I would like to be able to catch this error to avoid error messages in the final application.
According to the tcpclient page, there is a callback property called ErrorOccurredFcn that seems to be built to handle that.
However, even with the following code, I still get the same "Error using asyncio.MessageHandler/onError" error and my error handler function is not executed.
function error_handler()
disp("Asynchronous error handled"); % never executed
end
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
t.ErrorOccurredFcn = @error_handler;
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
So, I still get an error in the command window after using the ErrorOccurredFcn callback property.
The read() command does not seem to raise an exception whenever the server is disconnected.
So, what is the proper way to detect if the server is disconnected without getting an error in the command window? I am using the tcpclient() function to establish a connection to a server I built and I would like to be able to detect when the server disconnects. My current understanding is that the way to do that is to attempt a write and if the write fails, the connection can be considered as disconnected.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434); %connects to server
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
The above code works fine as expected.
Next, I run the same code, but I disconnect the server after the connection is established but before the write is sent.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
write(t,msg); % sends message to disconnected server. "An established connection was terminated. Please create a new TCPCLIENT." is shown in command window
write(t,msg); % sends message to disconnected server. "Invalid or deleted object." is shown in command window.
I can handle the last 2 errors using a try/catch, but I am not able to handle the "Error using asyncio.MessageHandler/onError" error with a try/catch.
I think this is because the error is raised asynchronously. I would like to be able to catch this error to avoid error messages in the final application.
According to the tcpclient page, there is a callback property called ErrorOccurredFcn that seems to be built to handle that.
However, even with the following code, I still get the same "Error using asyncio.MessageHandler/onError" error and my error handler function is not executed.
function error_handler()
disp("Asynchronous error handled"); % never executed
end
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
t.ErrorOccurredFcn = @error_handler;
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
So, I still get an error in the command window after using the ErrorOccurredFcn callback property.
The read() command does not seem to raise an exception whenever the server is disconnected.
So, what is the proper way to detect if the server is disconnected without getting an error in the command window? tcpclient, erroroccurredfcn, write, disconnect, disconnection MATLAB Answers — New Questions
can someone help me? when I want to insert the plaintext and also the matrix to the hill cipher, syntax out: Error using hillspasi (line 2) Not enough input arguments. is there something wrong in my code?
function hillspasi(x,k)
[r,c]=size(k);
if r~=c %jika jumlah baris tidak sama dengan jumlah kolom
disp(‘Kunci harus matrik bujur sangkar’)
else
data=upper(x);
if ismember(‘ ‘,data)==1 %cek inputan mengandung spasi
spasi=find(data==’ ‘);
km=size(spasi,2);
else
spasi=0;
end;
n=size(data,2);
xx=[];
a=0;
for i=1:n %menghilangkan spasi pada input jika ada
if data(i)~=’ ‘
a=a+1;
xx=[xx data(i)];
end;
end;
s=mod(a,r);
if s~=0
ss=r-s;
sss=[];
for i=1:ss
sss=[sss ‘X’ ];
end;
xx=[xx sss];
a=a+ss;
else
ss=0;
end;
i=1;
h=[];
while i<=a
m=[];
for j=i:(i-1+r)
m=[m xx(j)];
end;
m=double(m)-65;
c=mod(k*m’,26);
c=(c+65)’;
h=[h char(c)];
i=i+r;
end;
if spasi~=0
hx=[];j=1;kk=0;
sj=spasi(j);
for i=1:n+ss
if i==sj
hx=[hx ‘ ‘];
j=j+1;
if j<=km
sj=spasi(j);
end;
else
kk=kk+1;
if kk<=a
d=h(kk);
hx=[hx d];
end;
end;
end;
else
hx=h;
end;
hh=[];
for i=1:n
hh=[hh hx(i)];
end;
disp(‘CIPHER : ‘)
disp(‘~~~~~~~~’)
disp(hx)
if ~isequal(hx,hh)
disp(‘ ‘)
disp(‘CIPHER DENGAN MENGHILANGKAN KARAKTER TAMBAHAN :’)
disp(‘~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~’)
disp(hh)
end;
end;function hillspasi(x,k)
[r,c]=size(k);
if r~=c %jika jumlah baris tidak sama dengan jumlah kolom
disp(‘Kunci harus matrik bujur sangkar’)
else
data=upper(x);
if ismember(‘ ‘,data)==1 %cek inputan mengandung spasi
spasi=find(data==’ ‘);
km=size(spasi,2);
else
spasi=0;
end;
n=size(data,2);
xx=[];
a=0;
for i=1:n %menghilangkan spasi pada input jika ada
if data(i)~=’ ‘
a=a+1;
xx=[xx data(i)];
end;
end;
s=mod(a,r);
if s~=0
ss=r-s;
sss=[];
for i=1:ss
sss=[sss ‘X’ ];
end;
xx=[xx sss];
a=a+ss;
else
ss=0;
end;
i=1;
h=[];
while i<=a
m=[];
for j=i:(i-1+r)
m=[m xx(j)];
end;
m=double(m)-65;
c=mod(k*m’,26);
c=(c+65)’;
h=[h char(c)];
i=i+r;
end;
if spasi~=0
hx=[];j=1;kk=0;
sj=spasi(j);
for i=1:n+ss
if i==sj
hx=[hx ‘ ‘];
j=j+1;
if j<=km
sj=spasi(j);
end;
else
kk=kk+1;
if kk<=a
d=h(kk);
hx=[hx d];
end;
end;
end;
else
hx=h;
end;
hh=[];
for i=1:n
hh=[hh hx(i)];
end;
disp(‘CIPHER : ‘)
disp(‘~~~~~~~~’)
disp(hx)
if ~isequal(hx,hh)
disp(‘ ‘)
disp(‘CIPHER DENGAN MENGHILANGKAN KARAKTER TAMBAHAN :’)
disp(‘~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~’)
disp(hh)
end;
end; function hillspasi(x,k)
[r,c]=size(k);
if r~=c %jika jumlah baris tidak sama dengan jumlah kolom
disp(‘Kunci harus matrik bujur sangkar’)
else
data=upper(x);
if ismember(‘ ‘,data)==1 %cek inputan mengandung spasi
spasi=find(data==’ ‘);
km=size(spasi,2);
else
spasi=0;
end;
n=size(data,2);
xx=[];
a=0;
for i=1:n %menghilangkan spasi pada input jika ada
if data(i)~=’ ‘
a=a+1;
xx=[xx data(i)];
end;
end;
s=mod(a,r);
if s~=0
ss=r-s;
sss=[];
for i=1:ss
sss=[sss ‘X’ ];
end;
xx=[xx sss];
a=a+ss;
else
ss=0;
end;
i=1;
h=[];
while i<=a
m=[];
for j=i:(i-1+r)
m=[m xx(j)];
end;
m=double(m)-65;
c=mod(k*m’,26);
c=(c+65)’;
h=[h char(c)];
i=i+r;
end;
if spasi~=0
hx=[];j=1;kk=0;
sj=spasi(j);
for i=1:n+ss
if i==sj
hx=[hx ‘ ‘];
j=j+1;
if j<=km
sj=spasi(j);
end;
else
kk=kk+1;
if kk<=a
d=h(kk);
hx=[hx d];
end;
end;
end;
else
hx=h;
end;
hh=[];
for i=1:n
hh=[hh hx(i)];
end;
disp(‘CIPHER : ‘)
disp(‘~~~~~~~~’)
disp(hx)
if ~isequal(hx,hh)
disp(‘ ‘)
disp(‘CIPHER DENGAN MENGHILANGKAN KARAKTER TAMBAHAN :’)
disp(‘~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~’)
disp(hh)
end;
end; function, hill cipher MATLAB Answers — New Questions
Issue with dispaly of 3D images created from multiple 2D slices
Hi,
I have multiple 2D grayscale image slices (all of them are of same dimensions). I need to stack them to dispaly 3D image. I tried cat function and then implay. But this just plays video, I am not able to see 3D image.
I came across many threads relevant to this. But I am not sure which one will serve the purpose.
I have attached few 2D grayscale slices here. Could someone please suggest the possible method to get 3D reconstruction from these images?Hi,
I have multiple 2D grayscale image slices (all of them are of same dimensions). I need to stack them to dispaly 3D image. I tried cat function and then implay. But this just plays video, I am not able to see 3D image.
I came across many threads relevant to this. But I am not sure which one will serve the purpose.
I have attached few 2D grayscale slices here. Could someone please suggest the possible method to get 3D reconstruction from these images? Hi,
I have multiple 2D grayscale image slices (all of them are of same dimensions). I need to stack them to dispaly 3D image. I tried cat function and then implay. But this just plays video, I am not able to see 3D image.
I came across many threads relevant to this. But I am not sure which one will serve the purpose.
I have attached few 2D grayscale slices here. Could someone please suggest the possible method to get 3D reconstruction from these images? 3d image, focalstacks, ct images, image3d, vol3d, image analysis MATLAB Answers — New Questions
Remove NaNs from uitable Matlab App
Is there any way to remove NaNs from the uitable? When i read in the table and there is empty cells, the uitable will present this as NaNs. Is there any way to change this to just show empty cells?
Cheers.Is there any way to remove NaNs from the uitable? When i read in the table and there is empty cells, the uitable will present this as NaNs. Is there any way to change this to just show empty cells?
Cheers. Is there any way to remove NaNs from the uitable? When i read in the table and there is empty cells, the uitable will present this as NaNs. Is there any way to change this to just show empty cells?
Cheers. uitable, table, nans, nan MATLAB Answers — New Questions
Issue with TimeControls getting stuck
I have these TCs running every day. However yesterday I noted it seems the TC execution got stuck for 2 of them? Below screenshot is from today, so it is weird these do not show the correct future time, also note the 1 min difference bw. Last Ran & Run At …
I now modifed and saved both and it seems they got "restarted" and now show the future date correctly. Hopefully that did not destroy the evidence 🙂 but you have below screenshot anyway.
Hope someone can figure out what made these get "stuck"?I have these TCs running every day. However yesterday I noted it seems the TC execution got stuck for 2 of them? Below screenshot is from today, so it is weird these do not show the correct future time, also note the 1 min difference bw. Last Ran & Run At …
I now modifed and saved both and it seems they got "restarted" and now show the future date correctly. Hopefully that did not destroy the evidence 🙂 but you have below screenshot anyway.
Hope someone can figure out what made these get "stuck"? I have these TCs running every day. However yesterday I noted it seems the TC execution got stuck for 2 of them? Below screenshot is from today, so it is weird these do not show the correct future time, also note the 1 min difference bw. Last Ran & Run At …
I now modifed and saved both and it seems they got "restarted" and now show the future date correctly. Hopefully that did not destroy the evidence 🙂 but you have below screenshot anyway.
Hope someone can figure out what made these get "stuck"? thingspeak MATLAB Answers — New Questions
Error using Table with New Installation of 2022a
When I run these simple commands, I get the following error. I’m not sure where to look to address this.
xmin=1; xmax=2; ymin=3; ymax=5;
tst = table(xmin,xmax,ymin,ymax);
Error using table
The specified superclass ‘matlab.mixin.indexing.RedefinesDot’ contains a parse error, cannot be
found on MATLAB’s search path, or is shadowed by another file with the same name.
I have been using version 2021a previously and 2022a was just installed.When I run these simple commands, I get the following error. I’m not sure where to look to address this.
xmin=1; xmax=2; ymin=3; ymax=5;
tst = table(xmin,xmax,ymin,ymax);
Error using table
The specified superclass ‘matlab.mixin.indexing.RedefinesDot’ contains a parse error, cannot be
found on MATLAB’s search path, or is shadowed by another file with the same name.
I have been using version 2021a previously and 2022a was just installed. When I run these simple commands, I get the following error. I’m not sure where to look to address this.
xmin=1; xmax=2; ymin=3; ymax=5;
tst = table(xmin,xmax,ymin,ymax);
Error using table
The specified superclass ‘matlab.mixin.indexing.RedefinesDot’ contains a parse error, cannot be
found on MATLAB’s search path, or is shadowed by another file with the same name.
I have been using version 2021a previously and 2022a was just installed. table MATLAB Answers — New Questions
Real-Time Interface between App in AppDesigner and Simulink using parsim
I would like to optimize my progress bar in my Matlab app, which I am building in AppDesigner. I am currently using the app to start my Simulink model with parsim and simulate several simulation runs. However, I do not get any feedback on the progress of the individual simulations. I got the Listener option as a tip. I have implemented this. The specially created updategui.m file works. My question is, how can I combine parsim and the call of the updategui.m file? As soon as the parsim command is executed, I can no longer execute anything else. However, according to the instructions, I have to execute the updategui.m file as soon as the simulation is running. Otherwise exec_event_listener does not work.
Thank you.I would like to optimize my progress bar in my Matlab app, which I am building in AppDesigner. I am currently using the app to start my Simulink model with parsim and simulate several simulation runs. However, I do not get any feedback on the progress of the individual simulations. I got the Listener option as a tip. I have implemented this. The specially created updategui.m file works. My question is, how can I combine parsim and the call of the updategui.m file? As soon as the parsim command is executed, I can no longer execute anything else. However, according to the instructions, I have to execute the updategui.m file as soon as the simulation is running. Otherwise exec_event_listener does not work.
Thank you. I would like to optimize my progress bar in my Matlab app, which I am building in AppDesigner. I am currently using the app to start my Simulink model with parsim and simulate several simulation runs. However, I do not get any feedback on the progress of the individual simulations. I got the Listener option as a tip. I have implemented this. The specially created updategui.m file works. My question is, how can I combine parsim and the call of the updategui.m file? As soon as the parsim command is executed, I can no longer execute anything else. However, according to the instructions, I have to execute the updategui.m file as soon as the simulation is running. Otherwise exec_event_listener does not work.
Thank you. parsim, exec_event_listener, appdesigner, simulink MATLAB Answers — New Questions
matrix auto creation problem
If I want to make a matrix that inserts M as the order and it directly create a matrix with numbers from 1-M*M in that matrix. How should I like complete it
m=input(‘insert the degree of matrix’)
for i=1:m
for j=1:m
a(i,j)=
endfor
endforIf I want to make a matrix that inserts M as the order and it directly create a matrix with numbers from 1-M*M in that matrix. How should I like complete it
m=input(‘insert the degree of matrix’)
for i=1:m
for j=1:m
a(i,j)=
endfor
endfor If I want to make a matrix that inserts M as the order and it directly create a matrix with numbers from 1-M*M in that matrix. How should I like complete it
m=input(‘insert the degree of matrix’)
for i=1:m
for j=1:m
a(i,j)=
endfor
endfor matrix, matrix manipulation, matrix array MATLAB Answers — New Questions
Memory Allocation Error While Running Simulink
Im trying a simulation, it takes 7-8 hours in doing the whole simulation, but when it stops i get these 3 warnings/errors, which are making me lose the whole simulation.
My computer specs are:
Intel® Core™ i7-9750H
16GB RAM (2×8) 2666 MHz
256GB SSD
I’ve tried analyzing CPU and RAM’s usage to try to find where the problem occurs. RAM’s usage is around 5-7 Gb when the simulation is running, but when it goes to 100% and it starts terminating it uses the whole capacity of the memory, which I think is causing errors to the simulation. I’ve tried both using my pc while running the simulation and without using it, but both times it ended like this.
Is there any fix to this problem?Im trying a simulation, it takes 7-8 hours in doing the whole simulation, but when it stops i get these 3 warnings/errors, which are making me lose the whole simulation.
My computer specs are:
Intel® Core™ i7-9750H
16GB RAM (2×8) 2666 MHz
256GB SSD
I’ve tried analyzing CPU and RAM’s usage to try to find where the problem occurs. RAM’s usage is around 5-7 Gb when the simulation is running, but when it goes to 100% and it starts terminating it uses the whole capacity of the memory, which I think is causing errors to the simulation. I’ve tried both using my pc while running the simulation and without using it, but both times it ended like this.
Is there any fix to this problem? Im trying a simulation, it takes 7-8 hours in doing the whole simulation, but when it stops i get these 3 warnings/errors, which are making me lose the whole simulation.
My computer specs are:
Intel® Core™ i7-9750H
16GB RAM (2×8) 2666 MHz
256GB SSD
I’ve tried analyzing CPU and RAM’s usage to try to find where the problem occurs. RAM’s usage is around 5-7 Gb when the simulation is running, but when it goes to 100% and it starts terminating it uses the whole capacity of the memory, which I think is causing errors to the simulation. I’ve tried both using my pc while running the simulation and without using it, but both times it ended like this.
Is there any fix to this problem? memory allocation error, simulink MATLAB Answers — New Questions
MPLAB XC8 C Compiler
I have a question
I have used MPLAB XC16 C Compiler and MPLAB XC32 C Compiler in MATLAB Simulink environment and it was very useful.
But can MPLAB XC8 C Compiler also be used in MATLAB Simulink?
I have read a lot of information on this site about MPLAB XC8 C Compiler, but I don’t understand anything.
Site address:
https://nl.mathworks.com/help/bugfinder/ref/mplabxc8ccompilercompilermicrochip.html?searchHighlight=XC8%20C%20Compiler&s_tid=srchtitle_support_results_1_XC8%20C%20Compiler#mw_08216afd-f7cc-4b49-bf9d-cc323f130c3e_seealso
thanks a lotI have a question
I have used MPLAB XC16 C Compiler and MPLAB XC32 C Compiler in MATLAB Simulink environment and it was very useful.
But can MPLAB XC8 C Compiler also be used in MATLAB Simulink?
I have read a lot of information on this site about MPLAB XC8 C Compiler, but I don’t understand anything.
Site address:
https://nl.mathworks.com/help/bugfinder/ref/mplabxc8ccompilercompilermicrochip.html?searchHighlight=XC8%20C%20Compiler&s_tid=srchtitle_support_results_1_XC8%20C%20Compiler#mw_08216afd-f7cc-4b49-bf9d-cc323f130c3e_seealso
thanks a lot I have a question
I have used MPLAB XC16 C Compiler and MPLAB XC32 C Compiler in MATLAB Simulink environment and it was very useful.
But can MPLAB XC8 C Compiler also be used in MATLAB Simulink?
I have read a lot of information on this site about MPLAB XC8 C Compiler, but I don’t understand anything.
Site address:
https://nl.mathworks.com/help/bugfinder/ref/mplabxc8ccompilercompilermicrochip.html?searchHighlight=XC8%20C%20Compiler&s_tid=srchtitle_support_results_1_XC8%20C%20Compiler#mw_08216afd-f7cc-4b49-bf9d-cc323f130c3e_seealso
thanks a lot mplab xc8 c compiler, mplab, simulink MATLAB Answers — New Questions
Automate install – pass license information
2023b – Setup.exe passing ‘installer_input.txt’ properties to help simplify the install for users, works great for install key and network license location etc but is there a way to also keep it interactive so user can select needed toolboxes? Dont really want to install them all if the user doesnt even want them.
I see refrences to mode= but seems that has been removed since 2020versions?
Is there an alternative in the 2023 versons?2023b – Setup.exe passing ‘installer_input.txt’ properties to help simplify the install for users, works great for install key and network license location etc but is there a way to also keep it interactive so user can select needed toolboxes? Dont really want to install them all if the user doesnt even want them.
I see refrences to mode= but seems that has been removed since 2020versions?
Is there an alternative in the 2023 versons? 2023b – Setup.exe passing ‘installer_input.txt’ properties to help simplify the install for users, works great for install key and network license location etc but is there a way to also keep it interactive so user can select needed toolboxes? Dont really want to install them all if the user doesnt even want them.
I see refrences to mode= but seems that has been removed since 2020versions?
Is there an alternative in the 2023 versons? automated install, silent install, interactive install MATLAB Answers — New Questions
“PyCapsule_Import could not import module ‘libmwbuffer’ “error when converting to numpy
Is this a bug unique to this version R2024a ? I have never seen such a error before, when I used the older version.Is this a bug unique to this version R2024a ? I have never seen such a error before, when I used the older version. Is this a bug unique to this version R2024a ? I have never seen such a error before, when I used the older version. numpy, libmwbuffer, matlab MATLAB Answers — New Questions
Unable to Insert Blocks by Typing Directly in Simulink (MATLAB 2017a)
Hi, I’m using MATLAB 2017a and Simulink, but when I click on the canvas and type a block name (e.g., "constant"), it only creates a comment, not a block.
Is this feature available in 2017a, or is there something I need to enable? If it’s not supported, is there a faster way to insert blocks?
Thanks for your help!Hi, I’m using MATLAB 2017a and Simulink, but when I click on the canvas and type a block name (e.g., "constant"), it only creates a comment, not a block.
Is this feature available in 2017a, or is there something I need to enable? If it’s not supported, is there a faster way to insert blocks?
Thanks for your help! Hi, I’m using MATLAB 2017a and Simulink, but when I click on the canvas and type a block name (e.g., "constant"), it only creates a comment, not a block.
Is this feature available in 2017a, or is there something I need to enable? If it’s not supported, is there a faster way to insert blocks?
Thanks for your help! simulink-blocks, blocks, simulink-issue, block-insertion, simulink MATLAB Answers — New Questions
How to modify modem.qammod for the latest MATLAB version?
clc ;
clear all ;
close all ;
m =512; % Total number of OFDM symbols
N =1024; % Length of each OFDM symbol
M =4; % Size of the Constellation ( M can be 4 , 8 , 16 ,32 , 64 , 128 , 256)
pilotFrequency =8 ; % Pilot Symbol insertion frequency
E =2; % Energy of each Pilot Symbol
Ncp =256 ; % Length of the Cyclic Prefix
Tx = modem.qammod (‘M’,M ) ; % Choosing the modulation format as M – ary Quadrature Amplitude Modulation (M- QAM )
Rx = modem.qamdemod (‘M’,M) ; % Fixing up the demodulation format at the receiving end as M – ary QAM
% ACO – OFDM Transmitter
Data = randi ([0 M-1] ,m , N ); % Generation of Random bits Matrix of size m by N
for k1 =1: m
for m1 =1: N
if mod ( m1 ,2) ==0 % Performing Modulo operation to extract the even subcarriers
Data ( k1 , m1 ) =0; % Setting the Even Subcarriers to Zero
end
end
end
DataMod = modulate ( Tx , Data ) ; % Performing Data Modulation
DataMod_serialtoparallel = DataMod .’; % Performing Serial to Parallel Conversion
PLoc = 1: pilotFrequency :N ; % Fixing the location of Pilot carrires
DLoc = setxor (1: N , PLoc ) ; % Fixing the location of Data subcarriers
DataMod_serialtoparallel ( PLoc ,:) = E*DataMod_serialtoparallel ( PLoc ,:) ; % Inserting Pilot carriers
datamat = DataMod_serialtoparallel ; % Assigning the total data including the pilots to a variable called datamat
% Computation of Hermitian Symmetry Criteria
datamat (1 ,:) =0; % Assigning the First subcarrier to Zero
datamat (513 ,:) =0; % Assigning the Middle Subcarrier to Zero
datamat (514:1024 ,:) = flipud ( conj ( datamat (2:512 ,:) )) ; % Illustrating that only half of the subcarriers are exploited for data transmission as the remaining half are flipped complex conjugate versions of the previous ones .
d_ifft = ifft (( datamat ) ) ; % Computation of IFFT operation
% Ensuring that only the positive portion of the signal is transmitted
for k2 =1: N
for m2 =1: m
if( d_ifft ( k2 , m2 ) <0)
d_ifft ( k2 , m2 ) =0;
end
end
end
d_ifft_paralleltoserial = d_ifft .’; % Parallel to Serial Conversion
CP_part = d_ifft_paralleltoserial (: ,end – Ncp +1: end) ; %Addition of Cyclic Prefix
ACOOFDM_CP =[ CP_part d_ifft_paralleltoserial ]; %Transmissin of ACO – OFDM signal
% VLC Channel Modeling
theta = 70; %LED semi – angle
ml = – log10 (2) / log10 ( cos ( theta ) ) ; % Computation of Lambertian Mode Number
APD =0.01; % Area of the photodiode
lx =5; ly =5; lz =3; % Size of the Dimensions of the Indoor Room Environment
h =2.15;
[ XT , YT ]= meshgrid ([ – lx /4 lx /4] ,[ – ly /4 ly /4]) ;
Nx = lx *5; Ny = ly *5;
x = linspace ( – lx /2 , lx /2 , Nx );
y = linspace ( – ly /2 , ly /2 , Ny );
[ XR , YR ]= meshgrid (x , y );
D1 = sqrt (( XR – XT (1 ,1) ) .^2+( YR – YT (1 ,1) ) .^2+ h ^2) ;
D2 = sqrt (( XR – XT (2 ,2) ) .^2+( YR – YT (2 ,2) ) .^2+ h ^2) ;
cosphi_A1 = h ./ D1 ;
receiver_angle = acosd ( cosphi_A1 ) ;
H_A1 =3600*(( ml +1) * APD .* cosphi_A1 .^( ml +1) ./(2* pi .* D1.^2) +( ml +1) * APD .* cosphi_A1 .^( ml +1) ./(2* pi .^2* D1.^2* D2 .^2) ) ; % Computation of VLC channel Impulse Response taking into consideration Non Line of Sight ( NLOS ) Environment
H_A2 = H_A1 ./ norm ( H_A1 );
d_channell = filter ( H_A2 (1 ,1:2) ,1 , ACOOFDM_CP .’) .’; %Illustration of channel effect on the transmitted ACO – OFDM signal
count =0;
snr_vector =0:1:30; % size of signal to noise ratio (SNR ) vector
for snr = snr_vector
SNR = snr + 10* log10 ( log2 (M ) ) ;
count = count +1 ;
ACOOFDM_with_chann = awgn(d_channell , SNR ,’measured’) ; % Addition of AWGN
% Receiver of ACO – OFDM
ACOOFDM_removal_CP = ACOOFDM_with_chann (: , Ncp+1: N + Ncp );
% Removal of Cyclic Prefix
ACOOFDM_serialtoparallel = ACOOFDM_removal_CP .’; %Serial to Parallel Conversion
ACOOFDM_parallel_fft = fft ( ACOOFDM_serialtoparallel) ;
% Computation of FFT operation
% Channel Estimation
TransmittedPilots = DataMod_serialtoparallel ( PLoc,:) ; % Extracting the transmitted pilots
ReceivedPilots = ACOOFDM_parallel_fft ( PLoc ,:) ;
%Extracting the received pilot tones effected by channel
for r =1:m
H_MMSE(: , r ) = MMSE(ReceivedPilots(: , r ) ,TransmittedPilots(: , r ), N, pilotFrequency, H_A2(1 ,1:2), SNR);% Minimum Mean SquareError ( MMSE ) Channel Estimation
end
HData_MMSE_parallel1 = H_MMSE.’;
ACOOFDM_SERIAL_MMSE = demodulate(Rx ,(ACOOFDM_parallel_fft.’)./( HData_MMSE_parallel1) ) ;
% Recovery of Pilots from the Original Transmitted signal and Received Signal
Data_no_pilots = Data (: , DLoc ) ;
Recovered_Pilot_MMSE = ACOOFDM_SERIAL_MMSE (: , DLoc ) ;
% Computation of Bit Error Rate
[~ , recoveredMMSE( count ) ]= biterr ( Data_no_pilots (: ,2:255) , Recovered_Pilot_MMSE (: ,2:255) ) ;
end
% Plotting the BER curves
semilogy ( snr_vector , recoveredMMSE ,’gs -‘,’LineWidth’,2) ;
axis ([0 30 10^ -4 1]) ;
grid on ;
function H_MMSE = MMSE(RxP,TxP,N,pilotFrequency,h_CIR,SNR)
% I modified the MMSE_CE function provided in :MIMO-OFDM Wireless
% Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim,
% Won Young Yang and Chung G. Kang
%2010 John Wiley & Sons (Asia) Pte Ltd
% The modification made the function more suitable with my OFDM Matlab code
noiseVar = 10^(SNR*0.1);
Np=N/pilotFrequency; % Number of Pilots
H_LS = RxP./TxP; % LS estimate
k=0:length(h_CIR)-1;
hh = h_CIR*h_CIR’;
% tmp = h_CIR.*conj(h_CIR).*k;
r = sum(h_CIR.*conj(h_CIR).*k)/hh;
r2 = (h_CIR.*conj(h_CIR).*k)*k.’/hh;
t_rms = sqrt(r2-r^2); % rms delay
D = 1j*2*pi*t_rms/N; % Denomerator of Eq. (6.16) page 192
K1 = repmat([0:N-1].’,1,Np);
K2 = repmat([0:Np-1],N,1);
rf = 1./(1+D*(K1-K2*pilotFrequency));
K3 = repmat([0:Np-1].’,1,Np);
K4 = repmat([0:Np-1],Np,1);
rf2 = 1./(1+D*pilotFrequency*(K3-K4));
Rhp = rf;
Rpp = rf2 + eye(length(H_LS),length(H_LS))/noiseVar;
H_MMSE = transpose(Rhp*inv(Rpp)*H_LS); % MMSE channel estimate
endclc ;
clear all ;
close all ;
m =512; % Total number of OFDM symbols
N =1024; % Length of each OFDM symbol
M =4; % Size of the Constellation ( M can be 4 , 8 , 16 ,32 , 64 , 128 , 256)
pilotFrequency =8 ; % Pilot Symbol insertion frequency
E =2; % Energy of each Pilot Symbol
Ncp =256 ; % Length of the Cyclic Prefix
Tx = modem.qammod (‘M’,M ) ; % Choosing the modulation format as M – ary Quadrature Amplitude Modulation (M- QAM )
Rx = modem.qamdemod (‘M’,M) ; % Fixing up the demodulation format at the receiving end as M – ary QAM
% ACO – OFDM Transmitter
Data = randi ([0 M-1] ,m , N ); % Generation of Random bits Matrix of size m by N
for k1 =1: m
for m1 =1: N
if mod ( m1 ,2) ==0 % Performing Modulo operation to extract the even subcarriers
Data ( k1 , m1 ) =0; % Setting the Even Subcarriers to Zero
end
end
end
DataMod = modulate ( Tx , Data ) ; % Performing Data Modulation
DataMod_serialtoparallel = DataMod .’; % Performing Serial to Parallel Conversion
PLoc = 1: pilotFrequency :N ; % Fixing the location of Pilot carrires
DLoc = setxor (1: N , PLoc ) ; % Fixing the location of Data subcarriers
DataMod_serialtoparallel ( PLoc ,:) = E*DataMod_serialtoparallel ( PLoc ,:) ; % Inserting Pilot carriers
datamat = DataMod_serialtoparallel ; % Assigning the total data including the pilots to a variable called datamat
% Computation of Hermitian Symmetry Criteria
datamat (1 ,:) =0; % Assigning the First subcarrier to Zero
datamat (513 ,:) =0; % Assigning the Middle Subcarrier to Zero
datamat (514:1024 ,:) = flipud ( conj ( datamat (2:512 ,:) )) ; % Illustrating that only half of the subcarriers are exploited for data transmission as the remaining half are flipped complex conjugate versions of the previous ones .
d_ifft = ifft (( datamat ) ) ; % Computation of IFFT operation
% Ensuring that only the positive portion of the signal is transmitted
for k2 =1: N
for m2 =1: m
if( d_ifft ( k2 , m2 ) <0)
d_ifft ( k2 , m2 ) =0;
end
end
end
d_ifft_paralleltoserial = d_ifft .’; % Parallel to Serial Conversion
CP_part = d_ifft_paralleltoserial (: ,end – Ncp +1: end) ; %Addition of Cyclic Prefix
ACOOFDM_CP =[ CP_part d_ifft_paralleltoserial ]; %Transmissin of ACO – OFDM signal
% VLC Channel Modeling
theta = 70; %LED semi – angle
ml = – log10 (2) / log10 ( cos ( theta ) ) ; % Computation of Lambertian Mode Number
APD =0.01; % Area of the photodiode
lx =5; ly =5; lz =3; % Size of the Dimensions of the Indoor Room Environment
h =2.15;
[ XT , YT ]= meshgrid ([ – lx /4 lx /4] ,[ – ly /4 ly /4]) ;
Nx = lx *5; Ny = ly *5;
x = linspace ( – lx /2 , lx /2 , Nx );
y = linspace ( – ly /2 , ly /2 , Ny );
[ XR , YR ]= meshgrid (x , y );
D1 = sqrt (( XR – XT (1 ,1) ) .^2+( YR – YT (1 ,1) ) .^2+ h ^2) ;
D2 = sqrt (( XR – XT (2 ,2) ) .^2+( YR – YT (2 ,2) ) .^2+ h ^2) ;
cosphi_A1 = h ./ D1 ;
receiver_angle = acosd ( cosphi_A1 ) ;
H_A1 =3600*(( ml +1) * APD .* cosphi_A1 .^( ml +1) ./(2* pi .* D1.^2) +( ml +1) * APD .* cosphi_A1 .^( ml +1) ./(2* pi .^2* D1.^2* D2 .^2) ) ; % Computation of VLC channel Impulse Response taking into consideration Non Line of Sight ( NLOS ) Environment
H_A2 = H_A1 ./ norm ( H_A1 );
d_channell = filter ( H_A2 (1 ,1:2) ,1 , ACOOFDM_CP .’) .’; %Illustration of channel effect on the transmitted ACO – OFDM signal
count =0;
snr_vector =0:1:30; % size of signal to noise ratio (SNR ) vector
for snr = snr_vector
SNR = snr + 10* log10 ( log2 (M ) ) ;
count = count +1 ;
ACOOFDM_with_chann = awgn(d_channell , SNR ,’measured’) ; % Addition of AWGN
% Receiver of ACO – OFDM
ACOOFDM_removal_CP = ACOOFDM_with_chann (: , Ncp+1: N + Ncp );
% Removal of Cyclic Prefix
ACOOFDM_serialtoparallel = ACOOFDM_removal_CP .’; %Serial to Parallel Conversion
ACOOFDM_parallel_fft = fft ( ACOOFDM_serialtoparallel) ;
% Computation of FFT operation
% Channel Estimation
TransmittedPilots = DataMod_serialtoparallel ( PLoc,:) ; % Extracting the transmitted pilots
ReceivedPilots = ACOOFDM_parallel_fft ( PLoc ,:) ;
%Extracting the received pilot tones effected by channel
for r =1:m
H_MMSE(: , r ) = MMSE(ReceivedPilots(: , r ) ,TransmittedPilots(: , r ), N, pilotFrequency, H_A2(1 ,1:2), SNR);% Minimum Mean SquareError ( MMSE ) Channel Estimation
end
HData_MMSE_parallel1 = H_MMSE.’;
ACOOFDM_SERIAL_MMSE = demodulate(Rx ,(ACOOFDM_parallel_fft.’)./( HData_MMSE_parallel1) ) ;
% Recovery of Pilots from the Original Transmitted signal and Received Signal
Data_no_pilots = Data (: , DLoc ) ;
Recovered_Pilot_MMSE = ACOOFDM_SERIAL_MMSE (: , DLoc ) ;
% Computation of Bit Error Rate
[~ , recoveredMMSE( count ) ]= biterr ( Data_no_pilots (: ,2:255) , Recovered_Pilot_MMSE (: ,2:255) ) ;
end
% Plotting the BER curves
semilogy ( snr_vector , recoveredMMSE ,’gs -‘,’LineWidth’,2) ;
axis ([0 30 10^ -4 1]) ;
grid on ;
function H_MMSE = MMSE(RxP,TxP,N,pilotFrequency,h_CIR,SNR)
% I modified the MMSE_CE function provided in :MIMO-OFDM Wireless
% Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim,
% Won Young Yang and Chung G. Kang
%2010 John Wiley & Sons (Asia) Pte Ltd
% The modification made the function more suitable with my OFDM Matlab code
noiseVar = 10^(SNR*0.1);
Np=N/pilotFrequency; % Number of Pilots
H_LS = RxP./TxP; % LS estimate
k=0:length(h_CIR)-1;
hh = h_CIR*h_CIR’;
% tmp = h_CIR.*conj(h_CIR).*k;
r = sum(h_CIR.*conj(h_CIR).*k)/hh;
r2 = (h_CIR.*conj(h_CIR).*k)*k.’/hh;
t_rms = sqrt(r2-r^2); % rms delay
D = 1j*2*pi*t_rms/N; % Denomerator of Eq. (6.16) page 192
K1 = repmat([0:N-1].’,1,Np);
K2 = repmat([0:Np-1],N,1);
rf = 1./(1+D*(K1-K2*pilotFrequency));
K3 = repmat([0:Np-1].’,1,Np);
K4 = repmat([0:Np-1],Np,1);
rf2 = 1./(1+D*pilotFrequency*(K3-K4));
Rhp = rf;
Rpp = rf2 + eye(length(H_LS),length(H_LS))/noiseVar;
H_MMSE = transpose(Rhp*inv(Rpp)*H_LS); % MMSE channel estimate
end clc ;
clear all ;
close all ;
m =512; % Total number of OFDM symbols
N =1024; % Length of each OFDM symbol
M =4; % Size of the Constellation ( M can be 4 , 8 , 16 ,32 , 64 , 128 , 256)
pilotFrequency =8 ; % Pilot Symbol insertion frequency
E =2; % Energy of each Pilot Symbol
Ncp =256 ; % Length of the Cyclic Prefix
Tx = modem.qammod (‘M’,M ) ; % Choosing the modulation format as M – ary Quadrature Amplitude Modulation (M- QAM )
Rx = modem.qamdemod (‘M’,M) ; % Fixing up the demodulation format at the receiving end as M – ary QAM
% ACO – OFDM Transmitter
Data = randi ([0 M-1] ,m , N ); % Generation of Random bits Matrix of size m by N
for k1 =1: m
for m1 =1: N
if mod ( m1 ,2) ==0 % Performing Modulo operation to extract the even subcarriers
Data ( k1 , m1 ) =0; % Setting the Even Subcarriers to Zero
end
end
end
DataMod = modulate ( Tx , Data ) ; % Performing Data Modulation
DataMod_serialtoparallel = DataMod .’; % Performing Serial to Parallel Conversion
PLoc = 1: pilotFrequency :N ; % Fixing the location of Pilot carrires
DLoc = setxor (1: N , PLoc ) ; % Fixing the location of Data subcarriers
DataMod_serialtoparallel ( PLoc ,:) = E*DataMod_serialtoparallel ( PLoc ,:) ; % Inserting Pilot carriers
datamat = DataMod_serialtoparallel ; % Assigning the total data including the pilots to a variable called datamat
% Computation of Hermitian Symmetry Criteria
datamat (1 ,:) =0; % Assigning the First subcarrier to Zero
datamat (513 ,:) =0; % Assigning the Middle Subcarrier to Zero
datamat (514:1024 ,:) = flipud ( conj ( datamat (2:512 ,:) )) ; % Illustrating that only half of the subcarriers are exploited for data transmission as the remaining half are flipped complex conjugate versions of the previous ones .
d_ifft = ifft (( datamat ) ) ; % Computation of IFFT operation
% Ensuring that only the positive portion of the signal is transmitted
for k2 =1: N
for m2 =1: m
if( d_ifft ( k2 , m2 ) <0)
d_ifft ( k2 , m2 ) =0;
end
end
end
d_ifft_paralleltoserial = d_ifft .’; % Parallel to Serial Conversion
CP_part = d_ifft_paralleltoserial (: ,end – Ncp +1: end) ; %Addition of Cyclic Prefix
ACOOFDM_CP =[ CP_part d_ifft_paralleltoserial ]; %Transmissin of ACO – OFDM signal
% VLC Channel Modeling
theta = 70; %LED semi – angle
ml = – log10 (2) / log10 ( cos ( theta ) ) ; % Computation of Lambertian Mode Number
APD =0.01; % Area of the photodiode
lx =5; ly =5; lz =3; % Size of the Dimensions of the Indoor Room Environment
h =2.15;
[ XT , YT ]= meshgrid ([ – lx /4 lx /4] ,[ – ly /4 ly /4]) ;
Nx = lx *5; Ny = ly *5;
x = linspace ( – lx /2 , lx /2 , Nx );
y = linspace ( – ly /2 , ly /2 , Ny );
[ XR , YR ]= meshgrid (x , y );
D1 = sqrt (( XR – XT (1 ,1) ) .^2+( YR – YT (1 ,1) ) .^2+ h ^2) ;
D2 = sqrt (( XR – XT (2 ,2) ) .^2+( YR – YT (2 ,2) ) .^2+ h ^2) ;
cosphi_A1 = h ./ D1 ;
receiver_angle = acosd ( cosphi_A1 ) ;
H_A1 =3600*(( ml +1) * APD .* cosphi_A1 .^( ml +1) ./(2* pi .* D1.^2) +( ml +1) * APD .* cosphi_A1 .^( ml +1) ./(2* pi .^2* D1.^2* D2 .^2) ) ; % Computation of VLC channel Impulse Response taking into consideration Non Line of Sight ( NLOS ) Environment
H_A2 = H_A1 ./ norm ( H_A1 );
d_channell = filter ( H_A2 (1 ,1:2) ,1 , ACOOFDM_CP .’) .’; %Illustration of channel effect on the transmitted ACO – OFDM signal
count =0;
snr_vector =0:1:30; % size of signal to noise ratio (SNR ) vector
for snr = snr_vector
SNR = snr + 10* log10 ( log2 (M ) ) ;
count = count +1 ;
ACOOFDM_with_chann = awgn(d_channell , SNR ,’measured’) ; % Addition of AWGN
% Receiver of ACO – OFDM
ACOOFDM_removal_CP = ACOOFDM_with_chann (: , Ncp+1: N + Ncp );
% Removal of Cyclic Prefix
ACOOFDM_serialtoparallel = ACOOFDM_removal_CP .’; %Serial to Parallel Conversion
ACOOFDM_parallel_fft = fft ( ACOOFDM_serialtoparallel) ;
% Computation of FFT operation
% Channel Estimation
TransmittedPilots = DataMod_serialtoparallel ( PLoc,:) ; % Extracting the transmitted pilots
ReceivedPilots = ACOOFDM_parallel_fft ( PLoc ,:) ;
%Extracting the received pilot tones effected by channel
for r =1:m
H_MMSE(: , r ) = MMSE(ReceivedPilots(: , r ) ,TransmittedPilots(: , r ), N, pilotFrequency, H_A2(1 ,1:2), SNR);% Minimum Mean SquareError ( MMSE ) Channel Estimation
end
HData_MMSE_parallel1 = H_MMSE.’;
ACOOFDM_SERIAL_MMSE = demodulate(Rx ,(ACOOFDM_parallel_fft.’)./( HData_MMSE_parallel1) ) ;
% Recovery of Pilots from the Original Transmitted signal and Received Signal
Data_no_pilots = Data (: , DLoc ) ;
Recovered_Pilot_MMSE = ACOOFDM_SERIAL_MMSE (: , DLoc ) ;
% Computation of Bit Error Rate
[~ , recoveredMMSE( count ) ]= biterr ( Data_no_pilots (: ,2:255) , Recovered_Pilot_MMSE (: ,2:255) ) ;
end
% Plotting the BER curves
semilogy ( snr_vector , recoveredMMSE ,’gs -‘,’LineWidth’,2) ;
axis ([0 30 10^ -4 1]) ;
grid on ;
function H_MMSE = MMSE(RxP,TxP,N,pilotFrequency,h_CIR,SNR)
% I modified the MMSE_CE function provided in :MIMO-OFDM Wireless
% Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim,
% Won Young Yang and Chung G. Kang
%2010 John Wiley & Sons (Asia) Pte Ltd
% The modification made the function more suitable with my OFDM Matlab code
noiseVar = 10^(SNR*0.1);
Np=N/pilotFrequency; % Number of Pilots
H_LS = RxP./TxP; % LS estimate
k=0:length(h_CIR)-1;
hh = h_CIR*h_CIR’;
% tmp = h_CIR.*conj(h_CIR).*k;
r = sum(h_CIR.*conj(h_CIR).*k)/hh;
r2 = (h_CIR.*conj(h_CIR).*k)*k.’/hh;
t_rms = sqrt(r2-r^2); % rms delay
D = 1j*2*pi*t_rms/N; % Denomerator of Eq. (6.16) page 192
K1 = repmat([0:N-1].’,1,Np);
K2 = repmat([0:Np-1],N,1);
rf = 1./(1+D*(K1-K2*pilotFrequency));
K3 = repmat([0:Np-1].’,1,Np);
K4 = repmat([0:Np-1],Np,1);
rf2 = 1./(1+D*pilotFrequency*(K3-K4));
Rhp = rf;
Rpp = rf2 + eye(length(H_LS),length(H_LS))/noiseVar;
H_MMSE = transpose(Rhp*inv(Rpp)*H_LS); % MMSE channel estimate
end matlab, ofdm, channel estimation, visible light communication, ber, snr, modem.qammod, qammod MATLAB Answers — New Questions