# I do not understand this error message

2 views (last 30 days)
mandy on 29 Apr 2015
Answered: Ken Atwell on 29 Apr 2015
Hi I am trying to plot something in matlab and it keeps coming up with the error (* inner matrix dimensions must agree) for line 15 which is the v1= line. Can someone explain why this is and show how I can fix it. Thanks clear all A=1; To=4; t=-To:To/100:To; wo=2*pi/To;
U1=0; v1=0;
a0=0; for n=1:2:19 BN1=(4/(pi*n)) BN2=(n*pi)/2 v1=(BN1*sin(wo*n*t)*cos(wo*n*t)); end
plot(t,a0+v1) axis ([-0.2 0.2 -15 15]) grid

Ken Atwell on 29 Apr 2015
MATLAB is trying to preform matrix multiplication when I think you want element-by-element multiplication instead. Replace * (asterisk) with .* (dot-asterisk) throughout and you should be all set.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8215229,"math_prob":0.6891872,"size":925,"snap":"2022-27-2022-33","text_gpt3_token_len":287,"char_repetition_ratio":0.078175895,"word_repetition_ratio":0.027210884,"special_character_ratio":0.31675676,"punctuation_ratio":0.10952381,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99179435,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-25T22:35:08Z\",\"WARC-Record-ID\":\"<urn:uuid:c4d6bf70-34b3-4bfc-b6fe-b684ea7e7fca>\",\"Content-Length\":\"105847\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:db7edb80-3017-405b-8b75-98d3b1296f22>\",\"WARC-Concurrent-To\":\"<urn:uuid:310a1f39-a35d-4dac-9744-db1c925a9d81>\",\"WARC-IP-Address\":\"104.68.243.15\",\"WARC-Target-URI\":\"https://in.mathworks.com/matlabcentral/answers/214088-i-do-not-understand-this-error-message\",\"WARC-Payload-Digest\":\"sha1:PZSX62UTCBXSKVABV4RHEHWPUELA6HHR\",\"WARC-Block-Digest\":\"sha1:KVUU7RTUSA6SABQFXJTYRK3SKUJSZNOB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103036176.7_warc_CC-MAIN-20220625220543-20220626010543-00448.warc.gz\"}"}