I am trying to write a MatLab program to form a table of values for time, V(t), I(t), P(t), W(t). I have Volts and Amps, but can't insert P(t) and W(t)

Current program looks like this:
clear
clc
format compact
syms t V I
t=0:.01:.25;
V=10*exp(-20*t);
I=-200*exp(-20*t);
table=[t;V;I];
fprintf('\n t=%0.2f V=%12.3e I=%12.3e',table);
So P=I*V and W=.5*(100e-6)*V^2
Everytime I insert these two formulas the program doesn't recognize the variables.

1 件のコメント

Robert Prestridge
Robert Prestridge 2015 年 11 月 30 日
Might be hard to see, but time runs from 0 to 0.25 in 0.1 increments

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

 採用された回答

t=0:.01:.25;
V=10*exp(-20*t);
I=-200*exp(-20*t);
P=I.*V;
W=0.5*(100e-6)*V.^2
table=[t;V;I;P;W];
fprintf('t=%0.2f V=%12.3e I=%12.3e P=%12.3e W=%12.3e\n',table);

1 件のコメント

Thorsten
Thorsten 2015 年 11 月 30 日
The solution is to use the point-wise operations .* and .^.

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

その他の回答 (1 件)

Robert Prestridge
Robert Prestridge 2015 年 11 月 30 日

0 投票

Thanks, that fixed the problem, forgot about the dot operations

カテゴリ

ヘルプ センター および File Exchange で Mathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by