Undefined function 'cos' for input arguments of type 'char'.
1 回表示 (過去 30 日間)
古いコメントを表示
Undefined function 'cos' for input arguments of type 'char'.
Error in EMF_Project (line 27)
Vg = ((Amp*cos(phi))+(1i*(Amp*sin(phi))));
I keep getting this error, if I remove the cos and sin it works fine but with them in it doesn't. Any thoughts on why?
prompt={'Enter The Generator Voltage Amplitude:','Enter Load Impedance:','Enter Characteristic Impedance:','Enter Length:','Enter The Generators Internal Impedance:','Enter Omega:','Enter The Reference Angle:'};
title='Please Provide the Information listed';
answer=inputdlg(prompt,title, [1 80]);
Amp = answer{1};
ZL = answer{2};
Zo = answer{3};
Length = answer{4};
Zg = answer{5};
w = answer{6};
phi = answer{7};
f = (w/(2*pi)); %calculating the frequency
Up = 3e8; %setting the phase velocity at the speed of light
Vg = ((Amp*cos(phi))+(1i*(Amp*sin(phi)))); %putting the generator voltage in the form of a complex # for later use.
lambda = (Up/f); %calculating the wavelength
0 件のコメント
採用された回答
Sabin
2024 年 1 月 19 日
inputdlg returns a cell array of character vectors containing one input per edit field, starting from the top of the dialog box. Use the str2num function to convert space-delimited and comma-delimited values into row vectors, and semicolon-delimited values into column vectors. For an example, see Convert Input to Numeric Values.
Because phi is a character, function cos will then error out. By converting answer to numeric values should solve the problem:
Amp = str2num(answer{1});
...
phi = str2num(answer{7});
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!