/*=================================================================
* The main routine analyzes all incoming (right-hand side) arguments
*
* Copyright 1984-2000 The MathWorks, Inc.
* $Revision: 1.14 $
*
*=================================================================*/
#include <stdio.h>
#include <string.h>
#include "mex.h"
void display_subscript(const mxArray *array_ptr, int index);
void get_characteristics(const mxArray *array_ptr);
mxClassID analyze_class(const mxArray *array_ptr);
/* Pass analyze_cell a pointer to a cell mxArray. Each element
in a cell mxArray is called a "cell"; each cell holds zero
or one mxArray. analyze_cell accesses each cell and displays
information about it. */
static void
analyze_cell(const mxArray *cell_array_ptr)
{
int total_num_of_cells;
int index;
const mxArray *cell_element_ptr;
total_num_of_cells = mxGetNumberOfElements(cell_array_ptr);
mexPrintf("total num of cells = %d\n", total_num_of_cells);
mexPrintf("\n");
/* Each cell mxArray contains m-by-n cells; Each of these cells
is an mxArray. */
for (index=0; index<total_num_of_cells; index++) {
mexPrintf("\n\n\t\tCell Element: ");
display_subscript(cell_array_ptr, index);
mexPrintf("\n");
cell_element_ptr = mxGetCell(cell_array_ptr, index);
if (cell_element_ptr == NULL)
mexPrintf("\tEmpty Cell\n");
else {
/* Display a top banner. */
mexPrintf("------------------------------------------------\n");
get_characteristics(cell_element_ptr);
analyze_class(cell_element_ptr);
mexPrintf("\n");
}
}
mexPrintf("\n");
}
/* Pass analyze_structure a pointer to a structure mxArray. Each element
in a structure mxArray holds one or more fields; each field holds zero
or one mxArray. analyze_structure accesses every field of every
element and displays information about it. */
static void
analyze_structure(const mxArray *structure_array_ptr)
{
int total_num_of_elements, number_of_fields, index, field_index;
const char *field_name;
const mxArray *field_array_ptr;
mexPrintf("\n");
total_num_of_elements = mxGetNumberOfElements(structure_array_ptr);
number_of_fields = mxGetNumberOfFields(structure_array_ptr);
/* Walk through each structure element. */
for (index=0; index<total_num_of_elements; index++) {
/* For the given index, walk through each field. */
for (field_index=0; field_index<number_of_fields; field_index++) {
mexPrintf("\n\t\t");
display_subscript(structure_array_ptr, index);
field_name = mxGetFieldNameByNumber(structure_array_ptr,
field_index);
mexPrintf(".%s\n", field_name);
field_array_ptr = mxGetFieldByNumber(structure_array_ptr,
index,
field_index);
if (field_array_ptr == NULL)
mexPrintf("\tEmpty Field\n");
else {
/* Display a top banner. */
mexPrintf("------------------------------------------------\n");
get_characteristics(field_array_ptr);
analyze_class(field_array_ptr);
mexPrintf("\n");
}
}
mexPrintf("\n\n");
}
}
/* Pass analyze_string a pointer to a char mxArray. Each element
in a char mxArray holds one 2-byte character (an mxChar);
analyze_string displays the contents of the input char mxArray
one row at a time. Since adjoining row elements are NOT stored in
successive indices, analyze_string has to do a bit of math to
figure out where the next letter in a string is stored. */
static void
analyze_string(const mxArray *string_array_ptr)
{
char *buf;
int number_of_dimensions;
const int *dims;
int buflen, d, page, total_number_of_pages, elements_per_page;
/* Allocate enough memory to hold the converted string. */
buflen = mxGetNumberOfElements(string_array_ptr) + 1;
buf = mxCalloc(buflen, sizeof(char));
/* Copy the string data from string_array_ptr and place it into buf. */
if (mxGetString(string_array_ptr, buf, buflen) != 0)
mexErrMsgTxt("Could not convert string data.");
/* Get the shape of the input mxArray. */
dims = mxGetDimensions(string_array_ptr);
number_of_dimensions = mxGetNumberOfDimensions(string_array_ptr);
elements_per_page = dims[0] * dims[1];
/* total_number_of_pages = dims[2] x dims[3] x ... x dims[N-1] */
total_number_of_pages = 1;
for (d=2; d<number_of_dimensions; d++)
total_number_of_pages *= dims[d];
for (page=0; page < total_number_of_pages; page++) {
int row;
/* On each page, walk through each row. */
for (row=0; row<dims[0]; row++) {
int column;
int index = (page * elements_per_page) + row;
mexPrintf("\t");
display_subscript(string_array_ptr, index);
mexPrintf(" ");
/* Walk along each column in the current row. */
for (column=0; column<dims[1]; column++) {
mexPrintf("%c",buf[index]);
index += dims[0];
}
mexPrintf("\n");
}
}
}
/* Pass analyze_sparse a pointer to a sparse mxArray. A sparse mxArray
only stores its nonzero elements. The values of the nonzero elements
are stored in the pr and pi arrays. The tricky part of analyzing
sparse mxArray's is figuring out the indices where the nonzero
elements are stored. (See the mxSetIr and mxSetJc reference pages
for details. */
static void
analyze_sparse(const mxArray *array_ptr)
{
double *pr, *pi;
int *ir, *jc;
int col, total=0;
int starting_row_index, stopping_row_index, current_row_index;
int n;
/* Get the starting positions of all four data arrays. */
pr = mxGetPr(array_ptr);
pi = mxGetPi(array_ptr);
ir = mxGetIr(array_ptr);
jc = mxGetJc(array_ptr);
/* Display the nonzero elements of the sparse array. */
n = mxGetN(array_ptr);
for (col=0; col<n; col++) {
starting_row_index = jc[col];
stopping_row_index = jc[col+1];
if (starting_row_index == stopping_row_index)
continue;
else {
for (current_row_index = starting_row_index;
current_row_index < stopping_row_index;
current_row_index++) {
if (mxIsComplex(array_ptr)) {
mexPrintf("\t(%d,%d) = %g+%g i\n", ir[current_row_index]+1,
col+1, pr[total], pi[total++]);
}
else
mexPrintf("\t(%d,%d) = %g\n", ir[current_row_index]+1,
col+1, pr[total++]);
}
}
}
}
static void
analyze_int8(const mxArray *array_ptr)
{
signed char *pr, *pi;
char total_num_of_elements, index;
pr = (signed char *)mxGetData(array_ptr);
pi = (signed char *)mxGetImagData(array_ptr);
total_num_of_elements = mxGetNumberOfElements(array_ptr);
for (index=0; index<total_num_of_elements; index++) {
mexPrintf("\t");
display_subscript(array_ptr, index);
if (mxIsComplex(array_ptr))
mexPrintf(" = %d + %di\n", *pr++, *pi++);
else
mexPrintf(" = %d\n", *pr++);
}
}
static void
analyze_uint8(const mxArray *array_ptr)
{
unsigned char *pr, *pi;
int total_num_of_elements, index;
pr = (unsigned char *)mxGetData(array_ptr);
pi = (unsigned char *)mxGetImagData(array_ptr);
total_num_of_elements = mxGetNumberOfElements(array_ptr);
for (index=0; index<total_num_of_elements; index++) {
mexPrintf("\t");
display_subscript(array_ptr, index);
if (mxIsComplex(array_ptr))
mexPrintf(" = %u + %ui\n", *pr, *pi++);
else
mexPrintf(" = %u\n", *pr++);
}
}
static void
analyze_int16(const mxArray *array_ptr)
{
short int *pr, *pi;
short int total_num_of_elements, index;
pr = (short int *)mxGetData(array_ptr);
pi = (short int *)mxGetImagData(array_ptr);
total_num_o
没有合适的资源?快使用搜索试试~ 我知道了~
853751mex.rar_MATLAB 以太网_mex_以太网_以太网 matlab
共24个文件
c:13个
m:4个
f:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 173 浏览量
2022-07-15
15:51:16
上传
评论
收藏 25KB RAR 举报
温馨提示
基于单片机嵌入式以太网接口编程matlab
资源详情
资源评论
资源推荐
收起资源包目录
853751mex.rar (24个子文件)
mexeval.m 831B
mexlockf.f 2KB
mexload.m 392B
explore.c 15KB
mexevalstring.c 1KB
mexload.c 3KB
mexatexit.cpp 2KB
mexsettrapflag.c 2KB
mexfeval.c 1KB
yprime.c 2KB
mexlock.c 2KB
mexfeval.m 562B
www.pudn.com.txt 218B
yprimef.f 554B
mexgetarray.c 3KB
mexatexit.c 2KB
yprime.m 1021B
mexcpp.cpp 3KB
mexget.c 2KB
explore.dll 20KB
mexeval.c 2KB
mexcallmatlab.c 3KB
yprimefg.f 3KB
mexfunction.c 1KB
共 24 条
- 1
邓凌佳
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0