Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Mex Problem

1 Ansicht (letzte 30 Tage)
Chris
Chris am 19 Jun. 2012
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Good Day,
I'm trying to test a mex function I wrote but keep getting the following:
Error: File: test.m Line: 3 Column: 31
Unexpected MATLAB expression.
What I want to do is pass the following arrays to my mex function that will double them:
TurbineComponentsBlade = ((1 1 1) (1 1 1; 1 1 1) (1 1 1) (1 1 1)) ;
TurbineComponentsBladeLength = 1;
TurbineComponentsHub = ((1 1 1) (1 1 1; 1 1 1) (1 1 1) (1 1 1)) ;
TurbineComponentsRotorFurl = ((1 1 1) (1 1 1; 1 1 1) (1 1 1) (1 1 1)) ;
TurbineComponentsNacelle = ((1 1 1) (1 1 1 ;1 1 1) (1 1 1) (1 1 1)) ;
TurbineComponentsTailfin = ((1 1 1) (1 1 1; 1 1 1) (1 1 1) (1 1 1)) ;
TurbineComponentsTower = ((1 1 1) (1 1 1; 1 1 1) (1 1 1) (1 1 1)) ;
TurbineComponentsSubstructure = ((1 1 1) (1 1 1; 1 1 1) (1 1 1) (1 1 1)) ;
The error I keep receiving is that the "1" in the first 3x1 matrix, 2nd location is unexpected. Also the "1" in the 3x3 matrix (5th location from left to right) is unexpected. I imagine my matlab coding is wrong since I'm still learning it but if anyone could help me it would be appreciated.

Antworten (2)

Walter Roberson
Walter Roberson am 19 Jun. 2012
3 x 1 matrix: [1; 1; 1]
3 x 3 matrix: [1 1 1; 1 1 1; 1 1 1]
Short forms for these are: ones(3,1) and ones(3,3)
You cannot combine a 3 x 1 matrix and a 3 x 3 matrix in a single variable unless you use cell arrays:
{ones(3,1) ones(3,3)}

Jan
Jan am 20 Jun. 2012
The Getting Started chapters of the documentation explain exhaustively, how vectors and arrays are written in valid Matlab syntax. It is strongly recommended to read at least these chapters of the documentation completely.

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by