File Exchange

## 2D Multiwall model

version 1.5.0.0 (6.01 KB) by
A fast implementation of the Multiwall model

4 Downloads

Updated 28 Jan 2020

View License

Compute 2D - MultiWall model

Usage
------

rs_amp = multiwall_model(TXpoint , RXpoint , walls , material , [L0] , [n]);

Inputs
-------

TXpoint Transmitter points (2 x Nt)
RXpoint Receiver points (2 x Nr)
walls Walls (4 x nwall) where [xi,0 ; yi,0 ; xi,1 ; yi,1] are coordinates of the i'th wall, i = 1,...,nwall.
material Material (2 x nwall) where [typei ; ni] reprensents type of wall and associated attenuation index, i = 1,...,nwall.
L0 Reference loss value at 1m (L0 = 40.2 default)
n Power decay factor (n = 2 default)

Outputs
-------
rs_amp Total power (Nt x Nr)

Compilation instruction : Please run mexme_multiwall_model
------------------------------

Run mexme_multiwall_model for compile the mex file (please be sure that mex -setup is ok on your platform).

Run test_multiwall_model for demo.

Please open multiwall_model.c for other examples

### Cite As

Sebastien PARIS (2020). 2D Multiwall model (https://www.mathworks.com/matlabcentral/fileexchange/20209-2d-multiwall-model), MATLAB Central File Exchange. Retrieved .

### Comments and Ratings (46)

Davide Amendolare

I can't find the list of materials

Ben

shubham gupta

please someone explain this c program.. i am trying to modify it for fire propagation ..

void multiwall_model(double *TXpoint, double *RXpoint , double *walls , double *material , double L0 , double n,double *rs_amp, int Nt , int Nr, int nwalls)
{
int i , j , k;
int id, jd, kd, iNt;
double x1 , x2 , x3 , x4, y1 , y2, y3, y4;
double disttr , Lfsl, L;
double denom , cx , cy , bx , by , dx , dy , t , u, nn = 5.0*n;

#ifdef OMP
int num_threads = min(MAX_THREADS,omp_get_num_procs()) ;
omp_set_num_threads(num_threads);
#endif
for (i=0 ; i < Nr ; i++)
{
id = i*2;
iNt = i*Nt;
x2 = RXpoint[0 + id];
y2 = RXpoint[1 + id];
for (j = 0 ; j < Nt ; j++)
{
jd = j*2;
x1 = TXpoint[0 + jd];
y1 = TXpoint[1 + jd];
bx = (x2 - x1);
by = (y2 - y1);
disttr = bx*bx + by*by;
Lfsl = max(L0 , L0 + nn*log(disttr));
L = Lfsl;
#ifdef OMP
#pragma omp parallel for default(none) private(k,kd,x3,y3,x4,y4,dx,dy,cx,cy,denom,t,u) shared (material,walls,nwalls,by,bx,x1,y1) reduction (+:L)
#endif
for (k = 0 ; k < nwalls ; k++)
{
kd = k*4;
x3 = walls[0 + kd];
y3 = walls[1 + kd];
x4 = walls[2 + kd];
y4 = walls[3 + kd];
dx = (x4 - x3);
dy = (y4 - y3);
cx = (x3 - x1);
cy = (y3 - y1);
denom = dy*bx - dx*by;
if (denom != 0)
{
t = (dy*cx - dx*cy)/denom;
u = (by*cx - bx*cy)/denom;
if ( (t >= 0) && (t <= 1) && (u >= 0) && (u <= 1) )
{
L += material[k*2 + 1];
}
}
}
rs_amp[j + iNt] = -L;
}
}
}

Giovanny

Buenas tardes
quisiera saber de donde saco las datos para los materiales de la paredes y así mismo como representa estos datos en los valores de cada columna correspondiente a la matriz de materiales

Michael

Mr. Paris,
I was wondering where you got the data for wall materials and the dimensions of the floor plan displayed, so if you could tell me that would be much appreciated.

-Michael

Sebastien PARIS

Mickeal,

remove the "s" line 241 in #endifs t #endif

Stupid CTRL+S add an extra s ... somewhere. I will update with this fix. Thank u for reporting.

Michael

Yes its puzzling me as well. Thank you for all of your help so far its much appreciated.

Sebastien PARIS

Hummm ... it's puzzling me ...
I will check tonight when I will have access to a W764 ...

Michael

ok, so I redownloaded all of the files and reinstalled the compiler and tried again and the same thing is happening. When I run the mex -v command, this is the error message I receive:
mex -v multiwall_model.c
***************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html
****************************************************************************

-> Default options filename found in C:\Users\wildcat\AppData\Roaming\MathWorks\MATLAB\R2012a
----------------------------------------------------------------
-> Options file = C:\Users\wildcat\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2012a
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
OPTIMFLAGS = /O2 /Oy- /DNDEBUG
DEBUGFLAGS = /Z7
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\wildcat\AppData\Local\Temp\mex_IMGr2e\templib.x" /MAP:"multiwall_model.mexw64.map"
LINKDEBUGFLAGS = /debug /PDB:"multiwall_model.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"multiwall_model.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------

--> cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\wildcat\AppData\Local\Temp\mex_IMGr2e\multiwall_model.obj -I"C:\Program Files\MATLAB\R2012a\extern\include" -I"C:\Program Files\MATLAB\R2012a\simulink\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 multiwall_model.c

multiwall_model.c
multiwall_model.c(179) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(186) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(193) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(289) : fatal error C1004: unexpected end-of-file found

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'multiwall_model.c' failed.

Error using mex (line 206)
Unable to complete successfully.

Michael

ok, so I redownloaded all of the files and reinstalled the compiler and tried again and the same thing is happening. When I run the mex -v command, this is the error message I receive:
mex -v multiwall_model.c
***************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html
****************************************************************************

-> Default options filename found in C:\Users\wildcat\AppData\Roaming\MathWorks\MATLAB\R2012a
----------------------------------------------------------------
-> Options file = C:\Users\wildcat\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2012a
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
OPTIMFLAGS = /O2 /Oy- /DNDEBUG
DEBUGFLAGS = /Z7
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\wildcat\AppData\Local\Temp\mex_IMGr2e\templib.x" /MAP:"multiwall_model.mexw64.map"
LINKDEBUGFLAGS = /debug /PDB:"multiwall_model.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"multiwall_model.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------

--> cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\wildcat\AppData\Local\Temp\mex_IMGr2e\multiwall_model.obj -I"C:\Program Files\MATLAB\R2012a\extern\include" -I"C:\Program Files\MATLAB\R2012a\simulink\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 multiwall_model.c

multiwall_model.c
multiwall_model.c(179) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(186) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(193) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(289) : fatal error C1004: unexpected end-of-file found

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'multiwall_model.c' failed.

Error using mex (line 206)
Unable to complete successfully.

Sebastien PARIS

sounds strange ... line 290 doesn't exist for me. Are u sure that u didn't modified the source somewhere ? (with another editor)
Try to copy/paste all the source in a new one and compile it

Michael

-> Default options filename found in C:\Users\wildcat\AppData\Roaming\MathWorks\MATLAB\R2012a
----------------------------------------------------------------
-> Options file = C:\Users\wildcat\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2012a
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
OPTIMFLAGS = /O2 /Oy- /DNDEBUG
DEBUGFLAGS = /Z7
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\wildcat\AppData\Local\Temp\mex_WVxqiL\templib.x" /MAP:"multiwall_model.mexw64.map"
LINKDEBUGFLAGS = /debug /PDB:"multiwall_model.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"multiwall_model.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------

--> cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\wildcat\AppData\Local\Temp\mex_WVxqiL\multiwall_model.obj -I"C:\Program Files\MATLAB\R2012a\extern\include" -I"C:\Program Files\MATLAB\R2012a\simulink\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 multiwall_model.c

multiwall_model.c
multiwall_model.c(179) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(186) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(193) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
multiwall_model.c(290) : fatal error C1004: unexpected end-of-file found

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'multiwall_model.c' failed.

Error using mex (line 206)
Unable to complete successfully.

Sebastien PARIS

can u compile (without OpenMP support) by :

mex -v multiwall_model.c

and copy/paste compilation log ?

Michael

yes win7 64, and visual studio 10.0 (not sure if that is 2010)

Sebastien PARIS

win7 64 ?, visual studio 2010 ? (SDK is extra API)...

Michael

Yes, I have run the mex setup. I am using windows 7, matlab version R2012a, and compiler Microsoft SDK 7.1

Sebastien PARIS

Michael,

Did you run at least once : "mex -setup"
What is your system ? OS, Matlab version, Compiler version ?

Michael

Yes, I receive an error running that as well. The error says it cannot complete the mex successfully.

Sebastien PARIS

Did you run mexme_multiwall_model to compile mex-files ?

Michael

Hello Mr. Paris,

This has helped me greatly on a project I am working on, however, when I run the test model and after I right click I receive an error saying: "Undefined function 'multiwall_model' for input arguments of type
'double'.

Error in test_multiwall_model (line 34)
rs_amp = multiwall_model(TXpoint ,RXpoint , walls ,
material , L0 , n);'

Thanks and any help would be greatly appreciated.

-Mike

Sebastien PARIS

Gowrishankar,

Please change your C compiler. You can use the free MSVC express from Microsoft. Please refer which MSCV express you can use according to you current Matlab version

Gowrishankar S

Dear All,

I'm getting the following error while compiling the multiwall_model.c file. Can anyone give me some pointer on how to rectify this error?

Thanks in advance

mex multiwall_model.c
lcc preprocessor warning: multiwall_model.c:241 Unknown preprocessor control endifs
lcc preprocessor error: multiwall_model.c:289 Unterminated #if/#ifdef/#ifndef
Warning multiwall_model.c: 236 local `double u' is not referenced
Warning multiwall_model.c: 236 local `double t' is not referenced
Warning multiwall_model.c: 236 local `double dy' is not referenced
Warning multiwall_model.c: 236 local `double dx' is not referenced
Warning multiwall_model.c: 236 local `double by' is not referenced
Warning multiwall_model.c: 236 local `double bx' is not referenced
Warning multiwall_model.c: 236 local `double cy' is not referenced
Warning multiwall_model.c: 236 local `double cx' is not referenced
Warning multiwall_model.c: 236 local `double denom' is not referenced
Warning multiwall_model.c: 235 local `double L' is not referenced
Warning multiwall_model.c: 235 local `double Lfsl' is not referenced
Warning multiwall_model.c: 235 local `double disttr' is not referenced
Warning multiwall_model.c: 234 local `double y4' is not referenced
Warning multiwall_model.c: 234 local `double y3' is not referenced
Warning multiwall_model.c: 234 local `double y2' is not referenced
Warning multiwall_model.c: 234 local `double _y1' is not referenced
Warning multiwall_model.c: 234 local `double x4' is not referenced
Warning multiwall_model.c: 234 local `double x3' is not referenced
Warning multiwall_model.c: 234 local `double x2' is not referenced
Warning multiwall_model.c: 234 local `double x1' is not referenced
Warning multiwall_model.c: 233 local `int iNt' is not referenced
Warning multiwall_model.c: 233 local `int kd' is not referenced
Warning multiwall_model.c: 233 local `int jd' is not referenced
Warning multiwall_model.c: 233 local `int id' is not referenced
Warning multiwall_model.c: 232 local `int k' is not referenced
Warning multiwall_model.c: 232 local `int j' is not referenced
Warning multiwall_model.c: 232 local `int i' is not referenced
Error multiwall_model.c: 288 syntax error; found `end of input' expecting `}'
2 errors, 28 warnings

C:\PROGRA~1\MATLAB\R2007A\BIN\MEX.PL: Error: Compile of 'multiwall_model.c' failed.

Sebastien PARIS

Thanks u. A small update with openMP support will be published soon.

Faisol Riza

It's ok then. Btw thank you very much. Your work is so good.

Sebastien PARIS

Faisol... Can't tell you, I can't remember this detail.

Faisol Riza

Hello Mr. Sebastien,

I wonder how you set the parameter of L0=40.2 in the m file. Whereas in the reference you attach in C file, it say 47,4. It is very helpfull if you would explain it.

Thank you very much

Sebastien PARIS

midavisdj,

No you can't process like directly. You must to some image processing to extract walls from your floorplan ....

midavisdj

Hi Sebastien

I need to know if I can use an image (.jpg) and use it as background.

Sebastien PARIS

Jachym: you have to fill according to your floorplan variables :

1) walls (4 x nwall) where [xi,0 ; yi,0 ; xi,1 ; yi,1] are coordinates of the i'th wall, i = 1,...,nwall.

2) material (2 x nwall) where [typei ; ni] reprensents type of wall and associated attenuation index, i = 1,...,nwall.

This part is the most boring to do from a floorplan.

Jachym

Hi Sebastien, thanks for your model. I would like to use it with my small floorplan (for my school work). Which file should I edit to define own walls place and walls materils?
I didn't find manual or something else about model.
Thanks
Jachym

Tanyer Alan

kimo

Hello again,
sorry but I figured out that the answer was NO.
I have two more questions please.
- Is it possible to take these phenomena easily and efficacely?
- Is the choice of the material matrix dimension (2*N) going in this direction (rather than (1*N))?
Thanks for your response and this vgood file.
Regards,

kimo

Hi,
Can you tell us please if the reflection, diffraction and refraction phenomena are taken into account?
Thanks for responding
Kimo

Sebastien PARIS

There is a reference in the top of the C-fille...

Regards,

michael

Sebastien,

can you please explain the mathematics behind the multi-wall model in your C file?
i know that it counts walls,
but how do you check that you pass them?

thank you

Sebastien PARIS

Ho yeah, it's true .... Update with this minor bug, thx you.

Ben Jones

To get it to work I had to change line 132 in multiwall_model.c from

#define MAX(a , b) ((a) >= (b) ? (a) : (b))

to

#define max(a , b) ((a) >= (b) ? (a) : (b))

Mohd Sharim

Hello Sir,

Can you please explain me for the usage of the .mw* file in MATLAB. Thanks

Mohd Sharim

Hello Mr. Sebastien Paris,

Thank you for your help regarding to my last question. Now I need your help to study path loss characteristic in 2D database. Here I got a 2D database. When I tried to load the database base using 'imread' command and then load the file in your multiwall model, MATLAB unable to load the file. So, if you have any idea regarding to this post, please help me Sir.

Thank You,

Sincerely Yours,

Sharim

Sebastien PARIS

Please open the *.c file and find the quoted reference.

Mohd Sharim

Hello Mr. Sebatien Paris,

I'm interested with the 2D Multiwall Model. Here Im just curious about the reference value and power factor decay that you used. May I know which propagation model that you referred for both of the values.

Thank You,

sincerely Yours,

Sharim

Sebastien PARIS

Ok, the getpts function is from the image processing toolbox. There are plenty of similar functions in the FEX.

Bing

Hello,
there is a problem,
??? Undefined function or variable 'getpts'.

Error in ==> test_multiwall_model at 27
[x , y] = getpts;

pls help,thank u

Sebastien PARIS

I don't understand your question. You have just to run the demo file 'test_multiwall_model.m'. data_mw is matlab data file. You can load it with the command load.

yon

hi
please how i make the (data_mw), the file appeare as winap medea player file.can you clear me that?

so thanks.

### Updates

 28 Jan 2020 1.5.0.0 Cleaned for modern Matlab version 7 Jul 2012 1.4.0.0 -Fix a typo bug introduced in the last update (thanks to Mickael) 13 Oct 2011 1.3.0.0 -Cleanup code -Add openMP support (to be compile with -DOMP directive and link with MKL) 4 Apr 2010 1.2.0.0 A minor bug in a #define and add mexme_multiwall_model 27 Nov 2009 1.1.0.0 -add mexme_multiwall_model, a better inputs description and some small speed-up 4 Sep 2008 1.0.0.0 Some minor speedup
##### MATLAB Release Compatibility
Created with R2016b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux