結果:
- 昨日までちゃんと動いていたのに・・
- ヘルプページ通りに書いているのに・・
MATLAB 関数がエラーを出すようになることありますよね(?)そんな時にみなさんがまず確認するもの、何かありますか?教えてください!
例えば
which -all plot
をコマンドウィンドウで実行して、もともと MATLAB で定義されている plot 関数(MATLAB のインストールフォルダにある plot 関数)がちゃんと頭に出てくるかどうか確認します。
キーと値の組み合わせでデータを格納できるディクショナリ。R2022bでdictionaryコマンドが登場し、最近のバージョンではreaddictionaryとwritedictionaryでJSONファイルからの読み込み・書き込みにも対応しました。
私はMIDIデータからピアノの演奏動画を作るプログラムで、ディクショナリを使いました。音のノート番号をキーにして、patchで白と黒で鍵盤を塗りつぶしたmatlab.graphics.Graphicsデータ型を値にしたディクショナリで保存して、MIDIで鳴らされた音のノート番号からlookupでグラフのオブジェクトを取得し、FaceColorを変更してハイライトするというもの。

コード例
%% MIDIデータの.matファイルを読み取ってピアノを描画するサンプル
fig = figure('Position', [34 328 1626 524]);
ax = axes;
whiteKeyY = [0 0 150 150];
whiteKeyColor = [1 1 1];
blackKeyY = [50 50 150 150];
blackKeyColor = [0.1 0.1 0.1];
edgeColor = [0 0 0];
% ディクショナリの定義
d = configureDictionary("double", "matlab.graphics.Graphics");
% 白鍵を描画
for n = 1:9
pos = 23*7*(n-1);
d = insert(d, 21 + (n-1)*12, patch([pos+5 pos+28 pos+28 pos+5],whiteKeyY, whiteKeyColor, 'EdgeColor', edgeColor, 'UserData', 21 + (n-1)*12));
d = insert(d, 23 + (n-1)*12, patch([pos+28 pos+51 pos+51 pos+28], whiteKeyY, whiteKeyColor, 'EdgeColor', edgeColor, 'UserData', 23 + (n-1)*12));
d = insert(d, 24 + (n-1)*12, patch([pos+51 pos+74 pos+74 pos+51], whiteKeyY, whiteKeyColor, 'EdgeColor', edgeColor, 'UserData', 24 + (n-1)*12));
if n < 9
d = insert(d, 26 + (n-1)*12, patch([pos+74 pos+97 pos+97 pos+74], whiteKeyY, whiteKeyColor, 'EdgeColor', edgeColor, 'UserData', 26 + (n-1)*12));
d = insert(d, 28 + (n-1)*12, patch([pos+97 pos+120 pos+120 pos+97], whiteKeyY, whiteKeyColor, 'EdgeColor', edgeColor, 'UserData', 28 + (n-1)*12));
d = insert(d, 29 + (n-1)*12, patch([pos+120 pos+143 pos+143 pos+120], whiteKeyY, whiteKeyColor, 'EdgeColor', edgeColor, 'UserData', 29 + (n-1)*12));
d = insert(d, 31 + (n-1)*12, patch([pos+143 pos+166 pos+166 pos+143], whiteKeyY, whiteKeyColor, 'EdgeColor', edgeColor, 'UserData', 31 + (n-1)*12));
end
end
% 黒鍵を描画。白鍵の上になるようにループを分けています
for n = 1:9
pos = 23*7*(n-1);
d = insert(d, 22 + (n-1)*12, patch([pos+23 pos+33 pos+33 pos+23], blackKeyY, blackKeyColor, 'EdgeColor', [0 0 0], 'UserData', 22 + (n-1)*12));
if n < 9
d = insert(d, 25 + (n-1)*12, patch([pos+69 pos+79 pos+79 pos+69], blackKeyY, blackKeyColor, 'EdgeColor', [0 0 0], 'UserData', 25 + (n-1)*12));
d = insert(d, 27 + (n-1)*12, patch([pos+92 pos+102 pos+102 pos+92], blackKeyY, blackKeyColor, 'EdgeColor', [0 0 0], 'UserData', 27 + (n-1)*12));
d = insert(d, 30 + (n-1)*12, patch([pos+138 pos+148 pos+148 pos+138], blackKeyY, blackKeyColor, 'EdgeColor', [0 0 0], 'UserData', 30 + (n-1)*12));
d = insert(d, 32 + (n-1)*12, patch([pos+161 pos+171 pos+171 pos+161], blackKeyY, blackKeyColor, 'EdgeColor', [0 0 0], 'UserData', 32 + (n-1)*12));
end
end
xticklabels({})
yticklabels({})
xlim([5 1362])
drawnow
%% MIDI音源の.matファイルを読み込み
matData = load('fur-elise.mat');
msg = matData.receivedMessages;
eventTimes = [msg.Timestamp] - msg(1).Timestamp;
n = 1;
numNotes = 0;
lastNote = 0;
highlightedCircles = cell(1, 127);
% 音が鳴った鍵盤だけハイライトする
tic
while toc < max(eventTimes)
if toc > eventTimes(n)
thisMsg = msg(n);
if thisMsg.Type == "NoteOn"
numNotes = numNotes + 1;
lastNote = thisMsg.Note;
thisPatch = lookup(d, thisMsg.Note);
thisPatch.FaceColor = '#CCFFCC';
drawnow
elseif thisMsg.Type == "NoteOff"
numNotes = 0;
thisPatch = lookup(d, thisMsg.Note);
[~, ~, wOrB] = calcNotePos(thisMsg.Note);
if wOrB == "w"
thisPatch.FaceColor = 'white';
else
thisPatch.FaceColor = 'black';
end
drawnow
end
n = n+1;
end
end
%% サブ関数
function [pianoPos, centerPos, wOrB] = calcNotePos(note)
tempVar = idivide(int64(note), int64(12)); % 12で割った商
pos = 23*7*(tempVar-1);
switch mod(note, 12)
case 0 % C
pianoPos = pos + 62.5;
centerPos = 30;
wOrB = "w";
case 2 % D
pianoPos = pos + 85.5;
centerPos = 30;
wOrB = "w";
case 4 % E
pianoPos = pos + 108.5;
centerPos = 30;
wOrB = "w";
case 5 % F
pianoPos = pos + 131.5;
centerPos = 30;
wOrB = "w";
case 7 % G
pianoPos = pos + 154.5;
centerPos = 30;
wOrB = "w";
case 9 % A
pianoPos = pos + 177.5;
centerPos = 30;
wOrB = "w";
case 11 % B
pianoPos = pos + 200.5;
centerPos = 30;
wOrB = "w";
case 1 % C#
pianoPos = pos + 69;
centerPos = 100;
wOrB = "b";
case 3 % D#
pianoPos = pos + 92;
centerPos = 100;
wOrB = "b";
case 6 % F#
pianoPos = pos + 138;
centerPos = 100;
wOrB = "b";
case 8 % G#
pianoPos = pos + 161;
centerPos = 100;
wOrB = "b";
case 10 % A#
pianoPos = pos + 184;
centerPos = 100;
wOrB = "b";
end
end
皆さんはディクショナリを使ってますか? もし使っていたら、どういう活用をしているか、聞かせてください!
どの方法を使う事が多いですか?他によく使う方法があれば教えてくださいー。
方法①
Livescript 上で for ループ内で描画を編集させて描いた動画は「アニメーションのエクスポート」から動画ファイルに出力するのが一番簡単ですね。再生速度やら細かい設定ができない点は要注意。

方法②
exportgraphics 関数で "Append" オプション指定で実現できるようになった(R2022a から)のでこれも便利ですね。
N = 100;
x = linspace(0,4*pi,N);
y = sin(x);
filename = 'animation_sample.gif'; % Specify the output file name
if exist(filename,'file')
delete(filename)
end
h = animatedline;
axis([0,4*pi,-1,1]) % x軸の表示範囲を固定
for k = 1:length(x)
addpoints(h,x(k),y(k)); % ループでデータを追加
exportgraphics(gca,filename,"Append",true)
end
方法③
R2021b 以前のバージョンだとこんな感じ。
各ループで画面キャプチャして、imwrite で動画ファイルにフレーム追加していくイメージです。"DelayTime" を使って細かい指定ができるので、必要に応じて今でも利用します。
for k = 1:length(x)
addpoints(h,x(k),y(k)); % ループでデータを追加
drawnow % グラフアップデート
frame = getframe(gcf); % Figure 画面をムービーフレーム(構造体)としてキャプチャ
tmp = frame2im(frame); % 画像に変更
[A,map] = rgb2ind(tmp,256); % RGB -> インデックス画像に
if k == 1 % 新規 gif ファイル作成
imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',0.2);
else % 以降、画像をアペンド
imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',0.2);
end
end
これからは生成AIでコードを1から書くという事が減ってくるのかと思いますが,皆さんがMATLABのコードを書く時に意識しているご自身のルールのようなものがあれば教えてください.
MATLAB言語は柔軟に書けますが,自然と個人個人のルールというものが出来上がってきているのでは,と思います.
私はParameter, Valueペアの引数がある関数はそれぞれのペアを新しい行に書く,というのをよくやります.
h = plot(x, y, "ro-", ...
"LineWidth", 2, ...
"MarkerSize", 10, ...
"MarkerFaceColor", "g");
Parameter=Valueでも同じです.
h = plot(x, y, "ro-", ...
LineWidth = 2, ...
MarkerSize = 10, ...
MarkerFaceColor = "g");
また,一時期は "=" を揃えることもやってました(今はやってませんが).
h = plot(x, y, "ro-", ...
LineWidth = 2, ...
MarkerSize = 10, ...
MarkerFaceColor = "g");
皆さんにはどのようなルールがありますか?
The Graphics and App Building Blog just launched its first article on R2025a features, authored by Chris Portal, the director of engineering for the MATLAB graphics and app building teams.
Over the next few months, we'll publish a series of articles that showcase our updated graphics system, introduce new tools and features, and provide valuable references enriched by the perspectives of those involved in their development.
To stay updated, you can subscribe to the blog (look for the option in the upper left corner of the blog page). We also encourage you to join the conversation—your comments and questions under each article help shape the discussion and guide future content.
昨日 5/29 にお台場で MATLAB EXPO が開催されました。ご参加くださった方々ありがとうございました!
私は AI 関連のデモ展示で解説員としても立っておりましたが、立ち寄ってくださる方が絶えず、ずっと喋り続けてました。また、講演後に「さっきのすごくね?」という会話が漏れ聞こえてきたのがハイライト。
参加されたみなさま、印象に残ったこと・気になった講演・ポスター・デモ・新機能等あったら教えてください!(次回に向けて運営面での感想も)

以前のEXPOでも参加・聴講したことがある
67%
知り合いから聞いた
0%
MathWorksからのプロモーション,EXPOサイトで知った
0%
今年のEXPO会場でたまたま見かけた
0%
ライトニングトークって何?
33%
3 票
Hello Community,
We're excited to announce that registration is now open for the MathWorks AUTOMOTIVE CONFERENCE 2025! This event presents a fantastic opportunity to connect with MathWorks and industry experts while exploring the latest trends in the automotive sector.
Event Details:
- Date: April 29, 2025
- Location: St. John’s Resort, Plymouth, MI
Featured Topics:
- Virtual Development
- Electrification
- Software Development
- AI in Engineering
Whether you're a professional in the automotive industry or simply interested in these cutting-edge topics, we highly encourage you to register for this conference.
We look forward to seeing you there!
We are excited to announce another update to our Discussions area: the new Contribution Widget! The new widget simplifies the process of creating diverse types of content, whether you're praising someone who has helped you, sharing tips and tricks, or polling the community.

Previously, creating various types of content required navigating multiple links or channels. With the new Contribution Widget, everything you need is conveniently located in one place.
Give it a try and let us know how we can further enhance your user experience.
P.S. Who has been particularly helpful to you lately? Create your first praise post and let them know!
Creating data visualizations
79%
Interpreting data visualizations
21%
28 票
Have you ever wanted to search for a community member but didn't know where to start? Or perhaps you knew where to search but couldn't find enough information from the results? You're not alone. Many community users have shared this frustration with us. That's why the community team is excited to introduce the new ‘People’ page to address this need.

What Does the ‘People’ Page Offer?
- Comprehensive User Search: Search for users across different applications seamlessly.
- Detailed User Information: View a list of community members along with additional details such as their join date, rankings, and total contributions.
- Sorting Options: Use the ‘sort by’ filter located below the search bar to organize the list according to your preferences.
- Easy Navigation: Access the Answers, File Exchange, and Cody Leaderboard by clicking the ‘Leaderboards’ button in the upper right corner.
In summary, the ‘People’ page provides a gateway to search for individuals and gain deeper insights into the community.
How Can You Access It?
Navigate to the global menu, click on the ‘More’ link, and you’ll find the ‘People’ option.

Now you know where to go if you want to search for a user. We encourage you to give it a try and share your feedback with us.
私の場合、前の会社が音楽認識アプリの会社で、アルゴリズム開発でFFTが使われていたことがきっかけでした。でも、MATLABのすごさが分かったのは、機械学習のオンライン講座で、Andrew Ngが、線型代数を使うと、数式と非常に近い構文のコードで問題が処理できることを学んだ時でした。
Let's celebrate what made 2024 memorable! Together, we made big impacts, hosted exciting events, and built new apps.


Resource links:
Toolbox 全部入りの MATLAB ライセンス
67%
まだ持っていない Toolbox (下記にコメントください)
0%
MATLAB T シャツ
17%
MATLAB ルービックキューブ
0%
MATLAB 靴下
6%
MathWorks オフィス訪問チケット
11%
18 票
この場は MATLAB や Simulink を使っている皆さんが、気軽に質問や情報交換ができる場所として作られました。日本語でも気軽に投稿ができるように今回日本語チャネルを解説します。
ユーザーの皆様とのやり取りを通じて、みんなで知識や経験を共有し、一緒にスキルアップしていきましょう。 どうぞお気軽にご参加ください。
そして日本語チャネル開設にあたってコメントくださった皆様、ありがとうございます!
We’d like to announce a change on the Machine Translation feature on MATLAB Answers.
When users are visiting our international domains (e.g. China or Japan), Answers provides the option to translate the content. Recently, we identified several security threats involving high-volume requests from certain IP addresses targeting our translation service.
As one of the countermeasures, we have now placed the Machine Translation feature behind a login requirement. While non-logged-in users will still see the 'Translate' button, it will be inactive (greyed out) until they log in.
We are actively collaborating with adjacent teams to develop solutions to better detect and block malicious requests.
Please let us know if you have any questions or concerns.
We will be updating the MATLAB Answers infrastructure at 1PM EST today. We do not expect any disruption of service during this time. However, if you notice any issues, please be patient and try again later. Thank you for your understanding.
Hello, MATLAB fans!
For years, many of you have expressed interest in getting your hands on some cool MathWorks merchandise. I'm thrilled to announce that the wait is over—the MathWorks Merch Shop is officially open!

In our shop, you'll find a variety of exciting items, including baseball caps, mugs, T-shirts, and YETI bottles.
Visit the shop today and explore all the fantastic merchandise we have to offer. Happy shopping!
We are thrilled to announce the grand prize winners of our MATLAB Shorts Mini Hack contest! This year, we invited the MATLAB Graphics and Charting team, the authors of the MATLAB functions used in every entry, to be our judges. After careful consideration, they have selected the top three winners:
Judge comments: Realism & detailed comments; wowed us with Manta Ray
2nd place – Jenny Bosten
Judge comments: Topical hacks : Auroras & Wind turbine; beautiful landscapes & nightscapes
3rd place - Vasilis Bellos
Judge comments: Nice algorithms & extra comments; can’t go wrong with Pumpkins
Judge comments: Impressive spring & cubes!
In addition, after validating the votes, we are pleased to announce the top 10 participants on the leaderboard:
Congratulations to all! Your creativity and skills have inspired many of us to explore and learn new skills, and make this contest a big success!