Error message "Error: Function definitions are not permitted in this context." for function with matrix
이전 댓글 표시
I'm reading in a 5x5 matrix from excel and a 1x5 vector from excel. I then need to multiply them together in a function. Unfortunately it must be in a function. I keep getting an error message of "Error: Function definitions are not permitted in this context." I'm not quite sure why I'm getting this error. Any help would be appreciated.
Here's my code so far
%%Read in data
A=xlsread('AandB','a:e')
b=xlsread('AandB','g:g')
%%Multiply A and B
function [x] = multiply(A,b)
x=A*b
end

채택된 답변
추가 답변 (1개)
Walter Roberson
2016년 3월 16일
0 개 추천
You cannot put a function definition in the same file as a script. You also cannot define a function at the command line. You can store the code for your function in multiply.m
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!