条件ごとに計算させるにはどうすればよいか
Mostra commenti meno recenti
ある行列A,B(A,Bはサインカーブをえがく)に対して
A>=0,B>=0,|A|>=|B| ならば arctan(B/A)
A>=0,B>=0,|A|<|B| ならば π/2-arctan(A/B)
A<0,B>=0,|A|<|B| ならば π/2+arctan(|A|/B)
A<0,B>=0,|A|>=|B| ならば π-arctan(B/|A|)
A<0,B<0,|A|>=|B| ならば π+arctan(B/A)
A<0,B<0,|A|<|B| ならば 3π/2-arctan(A/B)
A>=0,B<0,|A|<|B| ならば 3π/2+arctan(A/|B|)
A>=0,B<0,|A|>=|B| ならば 2π-arctan(|B|/A)
の計算を適用したいと考えています.1)
以下は途中経過なのですが,上の条件で場合分けして計算させるのがうまくいきません.
助言していただけると幸いです.
%Start of script(初期化)
close all; % close all figures
clear; % clear all variables
clc; % clear the command terminal
%変数の型の定義
format long
%読み込みたいファイルを現在のフォルダに入れ,読み込みたいファイルの名前を入力
M1=readmatrix('データ.txt');
%読み込んだファイルのサイズの確認
sz1=size(M1);
Asz1=sz1(1,1);
%格納する空の配列
%sinAとsinBの値を取得
A1=zeros(Asz1,1);
A1(1,1)=M1(1,1);
B1=zeros(Asz1,1);
B1(1,1)=M1(1,2);
T1=zeros(Asz1,1);
%サンプリングタイム
tc = 1/1000000;
t1 = 1/1000000;
for i=2:Asz1
T1(i,1)=t1;
%サンプリング間隔
t1=t1+tc;
%X軸移動量
A1(i,1)=M1(i,1);
B1(i,1)=M1(i,2);
end
%時間と信号値の行列
CA1 = cat(2,T1,A1);
CB1 = cat(2,T1,B1);
n1 = zeros(Asz1,1);
for j = 1:Asz1
n1(j,1) = atan(B1(j,1)/A1(j,1));
end
参考文献
Risposta accettata
Più risposte (1)
Gomen, kana tukaemasen.
% set up
x = rand(1,10)-0.5;
myfun = @(x)(sin(x));
% check return values
x
myfun
% indexing
condition = x<0
indices = find(condition)
x(condition)
x(indices)
% using anonymous function
y = myfun(x)
y = sin(x)
1 Commento
優輔 井内
il 4 Nov 2022
Categorie
Scopri di più su Specifying Target for Graphics Output in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
