フィルターのクリア

Multiplying matrices by a number

1 回表示 (過去 30 日間)
João
João 2013 年 12 月 22 日
コメント済み: João 2013 年 12 月 24 日
Hi all,
I have a matrix in matlab that I already divide in 52 matrices, now I want to multiply each one of this matrices by the same number.
Each one of the 52 matrices have the size 7*24.
So the code I used to read and divide the matrix is;
[num, preco] = xlsread('preco_2008', 'Folha1' , 'C3:Z368');
[M,N] = size(preco); %# Matrix size
nSub = 52; %# Number of submatrices
semana = mat2cell(preco,diff(round(linspace(0,M,nSub+1))),N);
Now I want to multiply "semana" by Txsemanal
IPC_2008=-0.5;
IPC_2013=-0.2;
Txmensal=(IPC_2013-IPC_2008)/(IPC_2008);
Txsemanal=Txmensal/4;
I already tried A = mtimes(semana,Txsemanal) and cellfun(@mtimes, semana, Txsemanal, 'UniformOutput', false)
But I getting and error.
Could you please help me with multiplication?

採用された回答

Image Analyst
Image Analyst 2013 年 12 月 23 日
preco is the text (strings) in your workbook. So you can't multiply words by numbers . Perhaps you meant to use num instead , which is an array of numerical types, most likely doubles.
  1 件のコメント
João
João 2013 年 12 月 24 日
Thx for the help, I already found my problem I was using dots in excel so I was getting numbers as text.

サインインしてコメントする。

その他の回答 (1 件)

ES
ES 2013 年 12 月 23 日
編集済み: ES 2013 年 12 月 23 日
[num, preco] contains cell array. mtimes does no support cell array inputs. so convert them to matrices using cell2mat - http://www.mathworks.in/help/matlab/ref/cell2mat.html

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by